annotate src/process-nt.c @ 290:c9fe270a4101 r21-0b43

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