annotate src/process-nt.c @ 282:c42ec1d1cded r21-0b39

Import from CVS: tag r21-0b39
author cvs
date Mon, 13 Aug 2007 10:33:18 +0200
parents 7df0dd720c89
children 57709be46d1b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
1 /* Asynchronous subprocess implemenation for Win32
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
2 Copyright (C) 1985, 1986, 1987, 1988, 1992, 1993, 1994, 1995
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
3 Free Software Foundation, Inc.
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
4 Copyright (C) 1995 Sun Microsystems, Inc.
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
5 Copyright (C) 1995, 1996 Ben Wing.
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
6
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
7 This file is part of XEmacs.
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
8
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
9 XEmacs is free software; you can redistribute it and/or modify it
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
11 Free Software Foundation; either version 2, or (at your option) any
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
12 later version.
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
13
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
17 for more details.
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
18
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
20 along with XEmacs; see the file COPYING. If not, write to
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
22 Boston, MA 02111-1307, USA. */
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
23
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
24 /* Written by Kirill M. Katsnelson <kkm@kis.ru>, April 1998 */
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
25
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
26 #include <config.h>
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
27 #include "lisp.h"
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
28
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
29 #include "hash.h"
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
30 #include "lstream.h"
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
31 #include "process.h"
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
32 #include "procimpl.h"
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
33 #include "sysdep.h"
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
34
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
35 #include <windows.h>
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
36 #include <shellapi.h>
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
37 #include <signal.h>
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
38 #ifdef HAVE_SOCKETS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
39 #include <winsock.h>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
40 #endif
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
41
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
42 /* Implemenation-specific data. Pointed to by Lisp_Process->process_data */
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
43 struct nt_process_data
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
44 {
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
45 HANDLE h_process;
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
46 };
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
47
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
48 #define NT_DATA(p) ((struct nt_process_data*)((p)->process_data))
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
49
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
50 /*-----------------------------------------------------------------------*/
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
51 /* Process helpers */
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
52 /*-----------------------------------------------------------------------*/
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
53
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
54 /* This one breaks process abstraction. Prototype is in console-msw.h,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
55 used by select_process method in event-msw.c */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
56 HANDLE
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
57 get_nt_process_handle (struct Lisp_Process *p)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
58 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
59 return (NT_DATA (p)->h_process);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 274
diff changeset
60 }
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
61
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
62 /*-----------------------------------------------------------------------*/
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
63 /* Running remote threads. See Microsoft Systems Journal 1994 Number 5 */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
64 /* Jeffrey Richter, Load Your 32-bit DLL into Another Process's Address..*/
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
65 /*-----------------------------------------------------------------------*/
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
66
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
67 typedef struct
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
68 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
69 HANDLE h_process;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
70 HANDLE h_thread;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
71 LPVOID address;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
72 } process_memory;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
73
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
74 /*
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
75 * Allocate SIZE bytes in H_PROCESS address space. Fill in PMC used
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
76 * further by other routines. Return nonzero if successful.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
77 *
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
78 * The memory in other process is allocated by creating a suspended
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
79 * thread. Initial stack of that thread is used as the memory
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
80 * block. The thread entry point is the routine ExitThread in
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
81 * kernel32.dll, so the allocated memory is freed just by resuming the
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
82 * thread, which immediately terminates after that.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
83 */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
84
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
85 static int
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
86 alloc_process_memory (HANDLE h_process, size_t size,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
87 process_memory* pmc)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
88 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
89 LPTHREAD_START_ROUTINE adr_ExitThread =
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
90 (LPTHREAD_START_ROUTINE)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
91 GetProcAddress (GetModuleHandle ("kernel32"), "ExitThread");
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
92 DWORD dw_unused;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
93 CONTEXT context;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
94 MEMORY_BASIC_INFORMATION mbi;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
95
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
96 pmc->h_process = h_process;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
97 pmc->h_thread = CreateRemoteThread (h_process, NULL, size,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
98 adr_ExitThread, NULL,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
99 CREATE_SUSPENDED, &dw_unused);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
100 if (pmc->h_thread == NULL)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
101 return 0;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
102
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
103 /* Get context, for thread's stack pointer */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
104 context.ContextFlags = CONTEXT_CONTROL;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
105 if (!GetThreadContext (pmc->h_thread, &context))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
106 goto failure;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
107
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
108 /* Determine base address of the committed range */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
109 if (sizeof(mbi) != VirtualQueryEx (h_process,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
110 #if defined (_X86_)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
111 (LPDWORD)context.Esp - 1,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
112 #elif defined (_ALPHA_)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
113 (LPDWORD)context.IntSp - 1,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
114 #else
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
115 #error Unknown processor architecture
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
116 #endif
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
117 &mbi, sizeof(mbi)))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
118 goto failure;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
119
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
120 /* Change the page protection of the allocated memory to executable,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
121 read, and write. */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
122 if (!VirtualProtectEx (h_process, mbi.BaseAddress, size,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
123 PAGE_EXECUTE_READWRITE, &dw_unused))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
124 goto failure;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
125
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
126 pmc->address = mbi.BaseAddress;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
127 return 1;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
128
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
129 failure:
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
130 ResumeThread (pmc->h_thread);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
131 pmc->address = 0;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
132 return 0;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
133 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
134
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
135 static void
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
136 free_process_memory (process_memory* pmc)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
137 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
138 ResumeThread (pmc->h_thread);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
139 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
140
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
141 /*
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
142 * Run ROUTINE in the context of process determined by H_PROCESS. The
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
143 * routine is passed the address of DATA as parameter. CODE_END is the
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
144 * address immediately after ROUTINE's code. DATA_SIZE is the size of
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
145 * DATA structure.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
146 *
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
147 * Note that the code must be positionally independent, and compiled
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
148 * without stack checks (they cause implicit calls into CRT so will
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
149 * fail). DATA should not refer any data in calling process, as both
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
150 * routine and its data are copied into remote process. Size of data
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
151 * and code together should not exceed one page (4K on x86 systems).
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
152 *
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
153 * Return the value returned by ROUTINE, or (DWORD)-1 if call failed.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
154 */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
155 static DWORD
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
156 run_in_other_process (HANDLE h_process,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
157 LPTHREAD_START_ROUTINE routine, LPVOID code_end,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
158 LPVOID data, size_t data_size)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
159 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
160 process_memory pm;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
161 size_t code_size = (LPBYTE)code_end - (LPBYTE)routine;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
162 /* Need at most 3 extra bytes of memory, for data alignment */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
163 size_t total_size = code_size + data_size + 3;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
164 LPVOID remote_data;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
165 HANDLE h_thread;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
166 DWORD dw_unused;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
167
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
168 /* Allocate memory */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
169 if (!alloc_process_memory (h_process, total_size, &pm))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
170 return (DWORD)-1;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
171
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
172 /* Copy code */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
173 if (!WriteProcessMemory (h_process, pm.address, (LPVOID)routine,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
174 code_size, NULL))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
175 goto failure;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
176
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
177 /* Copy data */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
178 if (data_size)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
179 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
180 remote_data = (LPBYTE)pm.address + ((code_size + 4) & ~3);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
181 if (!WriteProcessMemory (h_process, remote_data, data, data_size, NULL))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
182 goto failure;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
183 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
184 else
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
185 remote_data = NULL;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
186
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
187 /* Execute the remote copy of code, passing it remote data */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
188 h_thread = CreateRemoteThread (h_process, NULL, 0,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
189 (LPTHREAD_START_ROUTINE) pm.address,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
190 remote_data, 0, &dw_unused);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
191 if (h_thread == NULL)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
192 goto failure;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
193
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
194 /* Wait till thread finishes */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
195 WaitForSingleObject (h_thread, INFINITE);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
196
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
197 /* Free remote memory */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
198 free_process_memory (&pm);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
199
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
200 /* Return thread's exit code */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
201 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
202 DWORD exit_code;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
203 GetExitCodeThread (h_thread, &exit_code);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
204 CloseHandle (h_thread);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
205 return exit_code;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
206 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
207
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
208 failure:
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
209 free_process_memory (&pm);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
210 return (DWORD)-1;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
211 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
212
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
213 /*-----------------------------------------------------------------------*/
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
214 /* Sending signals */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
215 /*-----------------------------------------------------------------------*/
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
216
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
217 /*
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
218 * We handle the following signals:
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
219 *
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
220 * SIGKILL, SIGTERM, SIGQUIT - These three translate to ExitProcess
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
221 * executed by the remote process
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
222 * SIGINT - The remote process is sent CTRL_BREAK_EVENT
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
223 */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
224
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
225 /*
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
226 * Sending SIGKILL
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
227 */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
228 typedef struct
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
229 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
230 void (WINAPI *adr_ExitProcess) (UINT);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
231 } sigkill_data;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
232
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
233 static DWORD WINAPI
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
234 sigkill_proc (sigkill_data* data)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
235 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
236 (*data->adr_ExitProcess)(255);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
237 return 1;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
238 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
239
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
240 /* Watermark in code space */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
241 static void
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
242 sigkill_code_end (void)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
243 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
244 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
245
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
246 /*
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
247 * Sending break or control c
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
248 */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
249 typedef struct
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
250 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
251 BOOL (WINAPI *adr_GenerateConsoleCtrlEvent) (DWORD, DWORD);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
252 DWORD event;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
253 } sigint_data;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
254
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
255 static DWORD WINAPI
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
256 sigint_proc (sigint_data* data)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
257 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
258 return (*data->adr_GenerateConsoleCtrlEvent) (data->event, 0);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
259 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
260
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
261 /* Watermark in code space */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
262 static void
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
263 sigint_code_end (void)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
264 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
265 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
266
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
267 /*
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
268 * Enabling signals
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
269 */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
270 typedef struct
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
271 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
272 BOOL (WINAPI *adr_SetConsoleCtrlHandler) (LPVOID, BOOL);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
273 } sig_enable_data;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
274
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
275 static DWORD WINAPI
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
276 sig_enable_proc (sig_enable_data* data)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
277 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
278 (*data->adr_SetConsoleCtrlHandler) (NULL, FALSE);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
279 return 1;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
280 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
281
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
282 /* Watermark in code space */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
283 static void
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
284 sig_enable_code_end (void)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
285 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
286 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
287
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
288 /*
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
289 * Send signal SIGNO to process H_PROCESS.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
290 * Return nonzero if successful.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
291 */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
292
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
293 /* This code assigns a return value of GetProcAddress to function pointers
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
294 of many different types. Instead of heavy obscure casts, we just disable
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
295 warnings about assignments to different function pointer types. */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
296 #pragma warning (disable : 4113)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
297
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
298 static int
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
299 send_signal (HANDLE h_process, int signo)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
300 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
301 HMODULE h_kernel = GetModuleHandle ("kernel32");
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
302 DWORD retval;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
303
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
304 assert (h_kernel != NULL);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
305
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
306 switch (signo)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
307 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
308 case SIGKILL:
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
309 case SIGTERM:
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
310 case SIGQUIT:
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
311 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
312 sigkill_data d;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
313 d.adr_ExitProcess = GetProcAddress (h_kernel, "ExitProcess");
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
314 assert (d.adr_ExitProcess);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
315 retval = run_in_other_process (h_process,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
316 sigkill_proc, sigkill_code_end,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
317 &d, sizeof (d));
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
318 break;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
319 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
320 case SIGINT:
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
321 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
322 sigint_data d;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
323 d.adr_GenerateConsoleCtrlEvent =
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
324 GetProcAddress (h_kernel, "GenerateConsoleCtrlEvent");
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
325 assert (d.adr_GenerateConsoleCtrlEvent);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
326 d.event = CTRL_C_EVENT;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
327 retval = run_in_other_process (h_process,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
328 sigint_proc, sigint_code_end,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
329 &d, sizeof (d));
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
330 break;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
331 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
332 default:
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
333 assert (0);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
334 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
335
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
336 return (int)retval > 0 ? 1 : 0;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
337 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
338
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
339 /*
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
340 * Enable CTRL_C_EVENT handling in a new child process
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
341 */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
342 static void
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
343 enable_child_signals (HANDLE h_process)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
344 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
345 HMODULE h_kernel = GetModuleHandle ("kernel32");
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
346 sig_enable_data d;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
347
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
348 assert (h_kernel != NULL);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
349 d.adr_SetConsoleCtrlHandler =
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
350 GetProcAddress (h_kernel, "SetConsoleCtrlHandler");
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
351 assert (d.adr_SetConsoleCtrlHandler);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
352 run_in_other_process (h_process,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
353 sig_enable_proc, sig_enable_code_end,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
354 &d, sizeof (d));
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
355 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
356
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
357 #pragma warning (default : 4113)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
358
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
359 /*
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
360 * Signal error if SIGNO is not supported
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
361 */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
362 static void
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
363 validate_signal_number (int signo)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
364 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
365 if (signo != SIGKILL && signo != SIGTERM
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
366 && signo != SIGQUIT && signo != SIGINT)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
367 error ("Signal number %d not supported", signo);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
368 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
369
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
370 /*-----------------------------------------------------------------------*/
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
371 /* Process methods */
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
372 /*-----------------------------------------------------------------------*/
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
373
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
374 /*
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
375 * Allocate and initialize Lisp_Process->process_data
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
376 */
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
377
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
378 static void
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
379 nt_alloc_process_data (struct Lisp_Process *p)
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
380 {
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
381 p->process_data = xnew_and_zero (struct nt_process_data);
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
382 }
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
383
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
384 static void
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
385 nt_finalize_process_data (struct Lisp_Process *p, int for_disksave)
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
386 {
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
387 assert (!for_disksave);
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
388 if (NT_DATA(p)->h_process)
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
389 CloseHandle (NT_DATA(p)->h_process);
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
390 }
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
391
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
392 /*
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
393 * Initialize XEmacs process implemenation once
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
394 */
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
395 static void
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
396 nt_init_process (void)
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
397 {
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
398 /* Initialize winsock */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
399 WSADATA wsa_data;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
400 /* Request Winsock v1.1 Note the order: (minor=1, major=1) */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
401 WSAStartup (MAKEWORD (1,1), &wsa_data);
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
402 }
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
403
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
404 /*
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
405 * Fork off a subprocess. P is a pointer to newly created subprocess
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
406 * object. If this function signals, the caller is responsible for
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
407 * deleting (and finalizing) the process object.
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
408 *
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
409 * The method must return PID of the new proces, a (positive??? ####) number
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
410 * which fits into Lisp_Int. No return value indicates an error, the method
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
411 * must signal an error instead.
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
412 */
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
413
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
414 /* #### This function completely ignores Vprocess_environment */
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
415
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
416 static void
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
417 signal_cannot_launch (char* image_file, DWORD err)
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
418 {
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
419 mswindows_set_errno (err);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
420 error ("Starting \"%s\": %s", image_file, strerror (errno));
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
421 }
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
422
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
423 static int
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
424 nt_create_process (struct Lisp_Process *p,
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
425 char **argv, CONST char *current_dir)
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
426 {
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
427 HANDLE hmyshove, hmyslurp, hprocin, hprocout;
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
428 LPTSTR command_line;
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
429 BOOL do_io, windowed;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
430
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
431 /* Find out whether the application is windowed or not */
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
432 {
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
433 /* SHGetFileInfo tends to return ERROR_FILE_NOT_FOUND on most
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
434 errors. This leads to bogus error message. */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
435 DWORD image_type = SHGetFileInfo (argv[0], 0, NULL, 0, SHGFI_EXETYPE);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
436 if (image_type == 0)
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
437 signal_cannot_launch (argv[0], (GetLastError () == ERROR_FILE_NOT_FOUND
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
438 ? ERROR_BAD_FORMAT : GetLastError ()));
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
439 windowed = HIWORD (image_type) != 0;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
440 }
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
441
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
442 /* Decide whether to do I/O on process handles, or just mark the
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
443 process exited immediately upon successful launching. We do I/O if the
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
444 process is a console one, or if it is windowed but windowed_process_io
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
445 is non-zero */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
446 do_io = !windowed || windowed_process_io ;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
447
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
448 if (do_io)
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
449 {
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
450 /* Create two unidirectional named pipes */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
451 HANDLE htmp;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
452 SECURITY_ATTRIBUTES sa;
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
453
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
454 sa.nLength = sizeof(sa);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
455 sa.bInheritHandle = TRUE;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
456 sa.lpSecurityDescriptor = NULL;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
457
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
458 CreatePipe (&hprocin, &hmyshove, &sa, 0);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
459 CreatePipe (&hmyslurp, &hprocout, &sa, 0);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
460
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
461 /* Stupid Win32 allows to create a pipe with *both* ends either
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
462 inheritable or not. We need process ends inheritable, and local
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
463 ends not inheritable. */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
464 DuplicateHandle (GetCurrentProcess(), hmyshove, GetCurrentProcess(), &htmp,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
465 0, FALSE, DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
466 hmyshove = htmp;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
467 DuplicateHandle (GetCurrentProcess(), hmyslurp, GetCurrentProcess(), &htmp,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
468 0, FALSE, DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
469 hmyslurp = htmp;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
470 }
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
471
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
472 /* Convert an argv vector into Win32 style command line.
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
473
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
474 #### This works only for cmd, and not for cygwin bash. Perhaps,
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
475 instead of ad-hoc fiddling with different methods for quoting
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
476 process arguments in ntproc.c (disgust shudder), this must call a
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
477 smart lisp routine. The code here will be a fallback, if the
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
478 lisp function is not specified.
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
479 */
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
480 {
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
481 char** thisarg;
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
482 size_t size = 1;
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
483
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
484 for (thisarg = argv; *thisarg; ++thisarg)
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
485 size += strlen (*thisarg) + 1;
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
486
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
487 command_line = alloca_array (char, size);
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
488 *command_line = 0;
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
489
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
490 for (thisarg = argv; *thisarg; ++thisarg)
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
491 {
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
492 if (thisarg != argv)
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
493 strcat (command_line, " ");
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
494 strcat (command_line, *thisarg);
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
495 }
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
496 }
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
497
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
498 /* Create process */
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
499 {
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
500 STARTUPINFO si;
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
501 PROCESS_INFORMATION pi;
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
502 DWORD err;
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
503
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
504 xzero (si);
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
505 si.dwFlags = STARTF_USESHOWWINDOW;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
506 si.wShowWindow = windowed ? SW_SHOWNORMAL : SW_HIDE;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
507 if (do_io)
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
508 {
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
509 si.hStdInput = hprocin;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
510 si.hStdOutput = hprocout;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
511 si.hStdError = hprocout;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
512 si.dwFlags |= STARTF_USESTDHANDLES;
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
513 }
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
514
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
515 err = (CreateProcess (NULL, command_line, NULL, NULL, TRUE,
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
516 CREATE_NEW_CONSOLE | CREATE_NEW_PROCESS_GROUP
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
517 | CREATE_SUSPENDED,
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
518 NULL, current_dir, &si, &pi)
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
519 ? 0 : GetLastError ());
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
520
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
521 if (do_io)
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
522 {
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
523 /* These just have been inherited; we do not need a copy */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
524 CloseHandle (hprocin);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
525 CloseHandle (hprocout);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
526 }
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
527
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
528 /* Handle process creation failure */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
529 if (err)
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
530 {
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
531 if (do_io)
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
532 {
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
533 CloseHandle (hmyshove);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
534 CloseHandle (hmyslurp);
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
535 }
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
536 signal_cannot_launch (argv[0], GetLastError ());
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
537 }
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
538
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
539 /* The process started successfully */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
540 if (do_io)
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
541 {
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
542 NT_DATA(p)->h_process = pi.hProcess;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
543 init_process_io_handles (p, (void*)hmyslurp, (void*)hmyshove, 0);
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
544 }
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
545 else
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
546 {
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
547 /* Indicate as if the process has exited immediately. */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
548 p->status_symbol = Qexit;
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
549 CloseHandle (pi.hProcess);
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
550 }
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
551
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
552 if (!windowed)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
553 enable_child_signals (pi.hProcess);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
554
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
555 ResumeThread (pi.hThread);
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
556 CloseHandle (pi.hThread);
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
557
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
558 /* Hack to support Windows 95 negative pids */
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
559 return ((int)pi.dwProcessId < 0
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
560 ? -(int)pi.dwProcessId : (int)pi.dwProcessId);
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
561 }
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
562 }
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
563
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
564 /*
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
565 * This method is called to update status fields of the process
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
566 * structure. If the process has not existed, this method is expected
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
567 * to do nothing.
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
568 *
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
569 * The method is called only for real child processes.
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
570 */
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
571
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
572 static void
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
573 nt_update_status_if_terminated (struct Lisp_Process* p)
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
574 {
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
575 DWORD exit_code;
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
576 if (GetExitCodeProcess (NT_DATA(p)->h_process, &exit_code)
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
577 && exit_code != STILL_ACTIVE)
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
578 {
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
579 p->tick++;
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
580 p->core_dumped = 0;
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
581 /* The exit code can be a code returned by process, or an
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
582 NTSTATUS value. We cannot accurately handle the latter since
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
583 it is a full 32 bit integer */
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
584 if (exit_code & 0xC0000000)
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
585 {
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
586 p->status_symbol = Qsignal;
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
587 p->exit_code = exit_code & 0x1FFFFFFF;
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
588 }
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
589 else
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
590 {
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
591 p->status_symbol = Qexit;
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
592 p->exit_code = exit_code;
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
593 }
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
594 }
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
595 }
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
596
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
597 /*
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
598 * Stuff the entire contents of LSTREAM to the process ouptut pipe
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
599 */
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
600
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
601 /* #### If only this function could be somehow merged with
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
602 unix_send_process... */
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
603
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
604 static void
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
605 nt_send_process (Lisp_Object proc, struct lstream* lstream)
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
606 {
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
607 struct Lisp_Process *p = XPROCESS (proc);
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
608
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
609 /* use a reasonable-sized buffer (somewhere around the size of the
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
610 stream buffer) so as to avoid inundating the stream with blocked
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
611 data. */
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
612 Bufbyte chunkbuf[512];
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
613 Bytecount chunklen;
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
614
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
615 while (1)
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
616 {
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
617 int writeret;
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
618
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
619 chunklen = Lstream_read (lstream, chunkbuf, 512);
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
620 if (chunklen <= 0)
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
621 break; /* perhaps should abort() if < 0?
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
622 This should never happen. */
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
623
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
624 /* Lstream_write() will never successfully write less than the
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
625 amount sent in. In the worst case, it just buffers the
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
626 unwritten data. */
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
627 writeret = Lstream_write (XLSTREAM (DATA_OUTSTREAM(p)), chunkbuf,
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
628 chunklen);
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
629 if (writeret < 0)
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
630 {
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
631 p->status_symbol = Qexit;
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
632 p->exit_code = ERROR_BROKEN_PIPE;
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
633 p->core_dumped = 0;
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
634 p->tick++;
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
635 process_tick++;
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
636 deactivate_process (proc);
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
637 error ("Broken pipe error sending to process %s; closed it",
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
638 XSTRING_DATA (p->name));
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
639 }
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
640
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
641 while (Lstream_was_blocked_p (XLSTREAM (p->pipe_outstream)))
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
642 {
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
643 /* Buffer is full. Wait, accepting input; that may allow
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
644 the program to finish doing output and read more. */
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
645 Faccept_process_output (Qnil, make_int (1), Qnil);
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
646 Lstream_flush (XLSTREAM (p->pipe_outstream));
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
647 }
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
648 }
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
649 Lstream_flush (XLSTREAM (DATA_OUTSTREAM(p)));
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
650 }
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
651
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
652 /*
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
653 * Send a signal number SIGNO to PROCESS.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
654 * CURRENT_GROUP means send to the process group that currently owns
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
655 * the terminal being used to communicate with PROCESS.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
656 * This is used for various commands in shell mode.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
657 * If NOMSG is zero, insert signal-announcements into process's buffers
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
658 * right away.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
659 *
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
660 * If we can, we try to signal PROCESS by sending control characters
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
661 * down the pty. This allows us to signal inferiors who have changed
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
662 * their uid, for which killpg would return an EPERM error.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
663 *
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
664 * The method signals an error if the given SIGNO is not valid
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
665 */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
666
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
667 static void
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
668 nt_kill_child_process (Lisp_Object proc, int signo,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
669 int current_group, int nomsg)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
670 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
671 struct Lisp_Process *p = XPROCESS (proc);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
672
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
673 /* Signal error if SIGNO cannot be sent */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
674 validate_signal_number (signo);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
675
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
676 /* Send signal */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
677 if (!send_signal (NT_DATA(p)->h_process, signo))
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
678 error ("Cannot send signal to process");
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
679 }
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
680
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
681 /*
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
682 * Kill any process in the system given its PID.
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
683 *
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
684 * Returns zero if a signal successfully sent, or
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
685 * negative number upon failure
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
686 */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
687 static int
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
688 nt_kill_process_by_pid (int pid, int signo)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
689 {
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
690 HANDLE h_process;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
691 int send_result;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
692
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
693 /* Signal error if SIGNO cannot be sent */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
694 validate_signal_number (signo);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
695
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
696 /* Try to open the process with required privileges */
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
697 h_process = OpenProcess (PROCESS_CREATE_THREAD
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
698 | PROCESS_QUERY_INFORMATION
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
699 | PROCESS_VM_OPERATION
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
700 | PROCESS_VM_WRITE,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
701 FALSE, pid);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
702 if (h_process == NULL)
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
703 return -1;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
704
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
705 send_result = send_signal (h_process, signo);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
706
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
707 CloseHandle (h_process);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
708
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
709 return send_result ? 0 : -1;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
710 }
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
711
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
712 /*-----------------------------------------------------------------------*/
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
713 /* Sockets connections */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
714 /*-----------------------------------------------------------------------*/
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
715 #ifdef HAVE_SOCKETS
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
716
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
717 /* #### Hey MS, how long Winsock 2 for '95 will be in beta? */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
718
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
719 #define SOCK_TIMER_ID 666
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
720 #define XM_SOCKREPLY (WM_USER + 666)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
721
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
722 static int
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
723 get_internet_address (Lisp_Object host, struct sockaddr_in *address,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
724 Error_behavior errb)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
725 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
726 char buf [MAXGETHOSTSTRUCT];
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
727 HWND hwnd;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
728 HANDLE hasync;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
729 int success = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
730
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
731 address->sin_family = AF_INET;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
732
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
733 /* First check if HOST is already a numeric address */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
734 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
735 unsigned long inaddr = inet_addr (XSTRING_DATA (host));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
736 if (inaddr != INADDR_NONE)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
737 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
738 address->sin_addr.s_addr = inaddr;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
739 return 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
740 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
741 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
742
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
743 /* Create a window which will receive completion messages */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
744 hwnd = CreateWindow ("STATIC", NULL, WS_OVERLAPPED, 0, 0, 1, 1,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
745 NULL, NULL, NULL, NULL);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
746 assert (hwnd);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
747
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
748 /* Post name resolution request */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
749 hasync = WSAAsyncGetHostByName (hwnd, XM_SOCKREPLY, XSTRING_DATA (host),
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
750 buf, sizeof (buf));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
751 if (hasync == NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
752 goto done;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
753
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
754 /* Set a timer to poll for quit every 250 ms */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
755 SetTimer (hwnd, SOCK_TIMER_ID, 250, NULL);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
756
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
757 while (1)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
758 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
759 MSG msg;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
760 GetMessage (&msg, hwnd, 0, 0);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
761 if (msg.message == XM_SOCKREPLY)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
762 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
763 /* Ok, got an answer */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
764 if (WSAGETASYNCERROR(msg.lParam) == NO_ERROR)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
765 success = 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
766 goto done;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
767 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
768 else if (msg.message == WM_TIMER && msg.wParam == SOCK_TIMER_ID)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
769 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
770 if (QUITP)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
771 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
772 WSACancelAsyncRequest (hasync);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
773 KillTimer (hwnd, SOCK_TIMER_ID);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
774 DestroyWindow (hwnd);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
775 REALLY_QUIT;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
776 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
777 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
778 DispatchMessage (&msg);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
779 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
780
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
781 done:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
782 KillTimer (hwnd, SOCK_TIMER_ID);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
783 DestroyWindow (hwnd);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
784 if (success)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
785 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
786 /* BUF starts with struct hostent */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
787 struct hostent* he = (struct hostent*) buf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
788 address->sin_addr.s_addr = *(unsigned long*)he->h_addr_list[0];
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
789 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
790 return success;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
791 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
792
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
793 static Lisp_Object
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
794 nt_canonicalize_host_name (Lisp_Object host)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
795 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
796 struct sockaddr_in address;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
797
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
798 if (!get_internet_address (host, &address, ERROR_ME_NOT))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
799 return host;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
800
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
801 if (address.sin_family == AF_INET)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
802 return build_string (inet_ntoa (address.sin_addr));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
803 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
804 return host;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
805 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
806
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
807 /* open a TCP network connection to a given HOST/SERVICE. Treated
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
808 exactly like a normal process when reading and writing. Only
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
809 differences are in status display and process deletion. A network
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
810 connection has no PID; you cannot signal it. All you can do is
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
811 deactivate and close it via delete-process */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
812
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
813 static void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
814 nt_open_network_stream (Lisp_Object name, Lisp_Object host, Lisp_Object service,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
815 Lisp_Object family, void** vinfd, void** voutfd)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
816 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
817 struct sockaddr_in address;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
818 SOCKET s;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
819 int port;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
820 int retval;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
821
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
822 CHECK_STRING (host);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
823
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
824 if (!EQ (family, Qtcpip))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
825 error ("Unsupported protocol family \"%s\"",
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
826 string_data (symbol_name (XSYMBOL (family))));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
827
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
828 if (INTP (service))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
829 port = htons ((unsigned short) XINT (service));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
830 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
831 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
832 struct servent *svc_info;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
833 CHECK_STRING (service);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
834 svc_info = getservbyname ((char *) XSTRING_DATA (service), "tcp");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
835 if (svc_info == 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
836 error ("Unknown service \"%s\"", XSTRING_DATA (service));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
837 port = svc_info->s_port;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
838 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
839
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
840 get_internet_address (host, &address, ERROR_ME);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
841 address.sin_port = port;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
842
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
843 s = socket (address.sin_family, SOCK_STREAM, 0);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
844 if (s < 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
845 report_file_error ("error creating socket", list1 (name));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
846
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
847 /* We don't want to be blocked on connect */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
848 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
849 unsigned int nonblock = 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
850 ioctlsocket (s, FIONBIO, &nonblock);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
851 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
852
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
853 retval = connect (s, (struct sockaddr *) &address, sizeof (address));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
854 if (retval != NO_ERROR && WSAGetLastError() != WSAEWOULDBLOCK)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
855 goto connect_failed;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
856
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
857 /* Wait while connection is established */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
858 while (1)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
859 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
860 fd_set fdset;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
861 struct timeval tv;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
862 int nsel;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
863
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
864 if (QUITP)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
865 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
866 closesocket (s);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
867 REALLY_QUIT;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
868 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
869
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
870 /* Poll for quit every 250 ms */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
871 tv.tv_sec = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
872 tv.tv_usec = 250 * 1000;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
873
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
874 FD_ZERO (&fdset);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
875 FD_SET (s, &fdset);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
876 nsel = select (0, NULL, &fdset, &fdset, &tv);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
877
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
878 if (nsel > 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
879 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
880 /* Check was connnection successful or not */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
881 tv.tv_usec = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
882 nsel = select (0, NULL, NULL, &fdset, &tv);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
883 if (nsel > 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
884 goto connect_failed;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
885 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
886 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
887 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
888 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
889
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
890 /* We are connected at this point */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
891 *vinfd = (void*)s;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
892 DuplicateHandle (GetCurrentProcess(), (HANDLE)s,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
893 GetCurrentProcess(), (LPHANDLE)voutfd,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
894 0, FALSE, DUPLICATE_SAME_ACCESS);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
895 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
896
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
897 connect_failed:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
898 closesocket (s);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
899 report_file_error ("connection failed", list2 (host, name));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
900 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
901
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
902 #endif
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
903
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
904 /*-----------------------------------------------------------------------*/
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
905 /* Initialization */
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
906 /*-----------------------------------------------------------------------*/
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
907
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
908 void
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
909 process_type_create_nt (void)
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
910 {
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
911 PROCESS_HAS_METHOD (nt, alloc_process_data);
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
912 PROCESS_HAS_METHOD (nt, finalize_process_data);
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
913 PROCESS_HAS_METHOD (nt, init_process);
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
914 PROCESS_HAS_METHOD (nt, create_process);
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
915 PROCESS_HAS_METHOD (nt, update_status_if_terminated);
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
916 PROCESS_HAS_METHOD (nt, send_process);
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
917 PROCESS_HAS_METHOD (nt, kill_child_process);
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 278
diff changeset
918 PROCESS_HAS_METHOD (nt, kill_process_by_pid);
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
919 #ifdef HAVE_SOCKETS
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
920 PROCESS_HAS_METHOD (nt, canonicalize_host_name);
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
921 PROCESS_HAS_METHOD (nt, open_network_stream);
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
922 #ifdef HAVE_MULTICAST
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 280
diff changeset
923 #error I won't do this until '95 has winsock2
274
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
924 PROCESS_HAS_METHOD (nt, open_multicast_group);
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
925 #endif
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
926 #endif
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
927 }
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
928
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
929 void
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
930 vars_of_process_nt (void)
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
931 {
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
932 }
ca9a9ec9c1c1 Import from CVS: tag r21-0b35
cvs
parents:
diff changeset
933