Mercurial > emacs
annotate src/w32proc.c @ 47262:1c1d47728dc8
(idlwave-shell-use-breakpoint-glyph): Fix spacing.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Fri, 06 Sep 2002 07:16:22 +0000 |
parents | 514398573221 |
children | 23a1cea22d13 |
rev | line source |
---|---|
16884
36babc489b0c
Change all uses of win95, winnt, and win32
Geoff Voelker <voelker@cs.washington.edu>
parents:
16826
diff
changeset
|
1 /* Process support for GNU Emacs on the Microsoft W32 API. |
37290
6e6e46d239df
(sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents:
33694
diff
changeset
|
2 Copyright (C) 1992, 1995, 1999, 2000, 2001 Free Software Foundation, Inc. |
9907 | 3 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
4 This file is part of GNU Emacs. |
9907 | 5 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
6 GNU Emacs is free software; you can redistribute it and/or modify |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
7 it under the terms of the GNU General Public License as published by |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
8 the Free Software Foundation; either version 2, or (at your option) |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
9 any later version. |
9907 | 10 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
11 GNU Emacs is distributed in the hope that it will be useful, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
14 GNU General Public License for more details. |
9907 | 15 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
16 You should have received a copy of the GNU General Public License |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
17 along with GNU Emacs; see the file COPYING. If not, write to |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
19 Boston, MA 02111-1307, USA. |
9907 | 20 |
21 Drew Bliss Oct 14, 1993 | |
22 Adapted from alarm.c by Tim Fleehart | |
23 */ | |
24 | |
25 #include <stdio.h> | |
26 #include <stdlib.h> | |
27 #include <errno.h> | |
28 #include <io.h> | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
29 #include <fcntl.h> |
9907 | 30 #include <signal.h> |
45089 | 31 #include <sys/file.h> |
9907 | 32 |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
33 /* must include CRT headers *before* config.h */ |
42469 | 34 |
35 #ifdef HAVE_CONFIG_H | |
36 #include <config.h> | |
37 #endif | |
38 | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
39 #undef signal |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
40 #undef wait |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
41 #undef spawnve |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
42 #undef select |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
43 #undef kill |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
44 |
9907 | 45 #include <windows.h> |
31115
42753ce203f8
(IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents:
26526
diff
changeset
|
46 #ifdef __GNUC__ |
42753ce203f8
(IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents:
26526
diff
changeset
|
47 /* This definition is missing from mingw32 headers. */ |
42753ce203f8
(IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents:
26526
diff
changeset
|
48 extern BOOL WINAPI IsValidLocale(LCID, DWORD); |
42753ce203f8
(IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents:
26526
diff
changeset
|
49 #endif |
9907 | 50 |
51 #include "lisp.h" | |
16593
4ed80eda6fac
Use new names for w32 files
Geoff Voelker <voelker@cs.washington.edu>
parents:
16588
diff
changeset
|
52 #include "w32.h" |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
53 #include "w32heap.h" |
9907 | 54 #include "systime.h" |
13931
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
55 #include "syswait.h" |
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
56 #include "process.h" |
37703
d0b43907dca5
Include syssignal.h, to avoid compiler warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
37290
diff
changeset
|
57 #include "syssignal.h" |
21613
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
58 #include "w32term.h" |
13931
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
59 |
15201
43551ec4b69d
(Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15145
diff
changeset
|
60 /* Control whether spawnve quotes arguments as necessary to ensure |
43551ec4b69d
(Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15145
diff
changeset
|
61 correct parsing by child process. Because not all uses of spawnve |
43551ec4b69d
(Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15145
diff
changeset
|
62 are careful about constructing argv arrays, we make this behaviour |
43551ec4b69d
(Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15145
diff
changeset
|
63 conditional (off by default). */ |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
64 Lisp_Object Vw32_quote_process_args; |
15201
43551ec4b69d
(Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15145
diff
changeset
|
65 |
16000
b5ecd5022991
(Vwin32_start_process_show_window): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15419
diff
changeset
|
66 /* Control whether create_child causes the process' window to be |
b5ecd5022991
(Vwin32_start_process_show_window): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15419
diff
changeset
|
67 hidden. The default is nil. */ |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
68 Lisp_Object Vw32_start_process_show_window; |
16000
b5ecd5022991
(Vwin32_start_process_show_window): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15419
diff
changeset
|
69 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
70 /* Control whether create_child causes the process to inherit Emacs' |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
71 console window, or be given a new one of its own. The default is |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
72 nil, to allow multiple DOS programs to run on Win95. Having separate |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
73 consoles also allows Emacs to cleanly terminate process groups. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
74 Lisp_Object Vw32_start_process_share_console; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
75 |
23949
9f8417cca07b
(Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents:
23678
diff
changeset
|
76 /* Control whether create_child cause the process to inherit Emacs' |
9f8417cca07b
(Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents:
23678
diff
changeset
|
77 error mode setting. The default is t, to minimize the possibility of |
9f8417cca07b
(Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents:
23678
diff
changeset
|
78 subprocesses blocking when accessing unmounted drives. */ |
9f8417cca07b
(Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents:
23678
diff
changeset
|
79 Lisp_Object Vw32_start_process_inherit_error_mode; |
9f8417cca07b
(Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents:
23678
diff
changeset
|
80 |
15247
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
81 /* Time to sleep before reading from a subprocess output pipe - this |
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
82 avoids the inefficiency of frequently reading small amounts of data. |
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
83 This is primarily necessary for handling DOS processes on Windows 95, |
16884
36babc489b0c
Change all uses of win95, winnt, and win32
Geoff Voelker <voelker@cs.washington.edu>
parents:
16826
diff
changeset
|
84 but is useful for W32 processes on both Windows 95 and NT as well. */ |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
85 Lisp_Object Vw32_pipe_read_delay; |
15247
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
86 |
15325
5c8e4ef3137c
(Vwin32_downcase_file_names): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15247
diff
changeset
|
87 /* Control conversion of upper case file names to lower case. |
5c8e4ef3137c
(Vwin32_downcase_file_names): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15247
diff
changeset
|
88 nil means no, t means yes. */ |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
89 Lisp_Object Vw32_downcase_file_names; |
15325
5c8e4ef3137c
(Vwin32_downcase_file_names): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15247
diff
changeset
|
90 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
91 /* Control whether stat() attempts to generate fake but hopefully |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
92 "accurate" inode values, by hashing the absolute truenames of files. |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
93 This should detect aliasing between long and short names, but still |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
94 allows the possibility of hash collisions. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
95 Lisp_Object Vw32_generate_fake_inodes; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
96 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
97 /* Control whether stat() attempts to determine file type and link count |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
98 exactly, at the expense of slower operation. Since true hard links |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
99 are supported on NTFS volumes, this is only relevant on NT. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
100 Lisp_Object Vw32_get_true_file_attributes; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
101 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
102 Lisp_Object Qhigh, Qlow; |
15247
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
103 |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
104 #ifdef EMACSDEBUG |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
105 void _DebPrint (const char *fmt, ...) |
9907 | 106 { |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
107 char buf[1024]; |
9907 | 108 va_list args; |
109 | |
110 va_start (args, fmt); | |
111 vsprintf (buf, fmt, args); | |
112 va_end (args); | |
113 OutputDebugString (buf); | |
114 } | |
115 #endif | |
116 | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
117 typedef void (_CALLBACK_ *signal_handler)(int); |
9907 | 118 |
119 /* Signal handlers...SIG_DFL == 0 so this is initialized correctly. */ | |
120 static signal_handler sig_handlers[NSIG]; | |
121 | |
122 /* Fake signal implementation to record the SIGCHLD handler. */ | |
123 signal_handler | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
124 sys_signal (int sig, signal_handler handler) |
9907 | 125 { |
126 signal_handler old; | |
127 | |
128 if (sig != SIGCHLD) | |
129 { | |
130 errno = EINVAL; | |
131 return SIG_ERR; | |
132 } | |
133 old = sig_handlers[sig]; | |
134 sig_handlers[sig] = handler; | |
135 return old; | |
136 } | |
137 | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
138 /* Defined in <process.h> which conflicts with the local copy */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
139 #define _P_NOWAIT 1 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
140 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
141 /* Child process management list. */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
142 int child_proc_count = 0; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
143 child_process child_procs[ MAX_CHILDREN ]; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
144 child_process *dead_child = NULL; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
145 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
146 DWORD WINAPI reader_thread (void *arg); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
147 |
9907 | 148 /* Find an unused process slot. */ |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
149 child_process * |
9907 | 150 new_child (void) |
151 { | |
152 child_process *cp; | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
153 DWORD id; |
9907 | 154 |
155 for (cp = child_procs+(child_proc_count-1); cp >= child_procs; cp--) | |
156 if (!CHILD_ACTIVE (cp)) | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
157 goto Initialise; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
158 if (child_proc_count == MAX_CHILDREN) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
159 return NULL; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
160 cp = &child_procs[child_proc_count++]; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
161 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
162 Initialise: |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
163 memset (cp, 0, sizeof(*cp)); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
164 cp->fd = -1; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
165 cp->pid = -1; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
166 cp->procinfo.hProcess = NULL; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
167 cp->status = STATUS_READ_ERROR; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
168 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
169 /* use manual reset event so that select() will function properly */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
170 cp->char_avail = CreateEvent (NULL, TRUE, FALSE, NULL); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
171 if (cp->char_avail) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
172 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
173 cp->char_consumed = CreateEvent (NULL, FALSE, FALSE, NULL); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
174 if (cp->char_consumed) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
175 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
176 cp->thrd = CreateThread (NULL, 1024, reader_thread, cp, 0, &id); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
177 if (cp->thrd) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
178 return cp; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
179 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
180 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
181 delete_child (cp); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
182 return NULL; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
183 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
184 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
185 void |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
186 delete_child (child_process *cp) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
187 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
188 int i; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
189 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
190 /* Should not be deleting a child that is still needed. */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
191 for (i = 0; i < MAXDESC; i++) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
192 if (fd_info[i].cp == cp) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
193 abort (); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
194 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
195 if (!CHILD_ACTIVE (cp)) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
196 return; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
197 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
198 /* reap thread if necessary */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
199 if (cp->thrd) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
200 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
201 DWORD rc; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
202 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
203 if (GetExitCodeThread (cp->thrd, &rc) && rc == STILL_ACTIVE) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
204 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
205 /* let the thread exit cleanly if possible */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
206 cp->status = STATUS_READ_ERROR; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
207 SetEvent (cp->char_consumed); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
208 if (WaitForSingleObject (cp->thrd, 1000) != WAIT_OBJECT_0) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
209 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
210 DebPrint (("delete_child.WaitForSingleObject (thread) failed " |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
211 "with %lu for fd %ld\n", GetLastError (), cp->fd)); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
212 TerminateThread (cp->thrd, 0); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
213 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
214 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
215 CloseHandle (cp->thrd); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
216 cp->thrd = NULL; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
217 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
218 if (cp->char_avail) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
219 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
220 CloseHandle (cp->char_avail); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
221 cp->char_avail = NULL; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
222 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
223 if (cp->char_consumed) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
224 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
225 CloseHandle (cp->char_consumed); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
226 cp->char_consumed = NULL; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
227 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
228 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
229 /* update child_proc_count (highest numbered slot in use plus one) */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
230 if (cp == child_procs + child_proc_count - 1) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
231 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
232 for (i = child_proc_count-1; i >= 0; i--) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
233 if (CHILD_ACTIVE (&child_procs[i])) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
234 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
235 child_proc_count = i + 1; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
236 break; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
237 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
238 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
239 if (i < 0) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
240 child_proc_count = 0; |
9907 | 241 } |
242 | |
243 /* Find a child by pid. */ | |
244 static child_process * | |
245 find_child_pid (DWORD pid) | |
246 { | |
247 child_process *cp; | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
248 |
9907 | 249 for (cp = child_procs+(child_proc_count-1); cp >= child_procs; cp--) |
250 if (CHILD_ACTIVE (cp) && pid == cp->pid) | |
251 return cp; | |
252 return NULL; | |
253 } | |
254 | |
255 | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
256 /* Thread proc for child process and socket reader threads. Each thread |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
257 is normally blocked until woken by select() to check for input by |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
258 reading one char. When the read completes, char_avail is signalled |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
259 to wake up the select emulator and the thread blocks itself again. */ |
9907 | 260 DWORD WINAPI |
261 reader_thread (void *arg) | |
262 { | |
263 child_process *cp; | |
264 | |
265 /* Our identity */ | |
266 cp = (child_process *)arg; | |
267 | |
268 /* We have to wait for the go-ahead before we can start */ | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
269 if (cp == NULL |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
270 || WaitForSingleObject (cp->char_consumed, INFINITE) != WAIT_OBJECT_0) |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
271 return 1; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
272 |
9907 | 273 for (;;) |
274 { | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
275 int rc; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
276 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
277 rc = _sys_read_ahead (cp->fd); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
278 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
279 /* The name char_avail is a misnomer - it really just means the |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
280 read-ahead has completed, whether successfully or not. */ |
9907 | 281 if (!SetEvent (cp->char_avail)) |
282 { | |
283 DebPrint (("reader_thread.SetEvent failed with %lu for fd %ld\n", | |
284 GetLastError (), cp->fd)); | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
285 return 1; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
286 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
287 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
288 if (rc == STATUS_READ_ERROR) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
289 return 1; |
9907 | 290 |
291 /* If the read died, the child has died so let the thread die */ | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
292 if (rc == STATUS_READ_FAILED) |
9907 | 293 break; |
294 | |
295 /* Wait until our input is acknowledged before reading again */ | |
296 if (WaitForSingleObject (cp->char_consumed, INFINITE) != WAIT_OBJECT_0) | |
297 { | |
298 DebPrint (("reader_thread.WaitForSingleObject failed with " | |
299 "%lu for fd %ld\n", GetLastError (), cp->fd)); | |
300 break; | |
301 } | |
302 } | |
303 return 0; | |
304 } | |
305 | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
306 /* To avoid Emacs changing directory, we just record here the directory |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
307 the new process should start in. This is set just before calling |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
308 sys_spawnve, and is not generally valid at any other time. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
309 static char * process_dir; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
310 |
9907 | 311 static BOOL |
38022
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
312 create_child (char *exe, char *cmdline, char *env, int is_gui_app, |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
313 int * pPid, child_process *cp) |
9907 | 314 { |
315 STARTUPINFO start; | |
316 SECURITY_ATTRIBUTES sec_attrs; | |
31115
42753ce203f8
(IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents:
26526
diff
changeset
|
317 #if 0 |
9907 | 318 SECURITY_DESCRIPTOR sec_desc; |
31115
42753ce203f8
(IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents:
26526
diff
changeset
|
319 #endif |
23949
9f8417cca07b
(Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents:
23678
diff
changeset
|
320 DWORD flags; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
321 char dir[ MAXPATHLEN ]; |
9907 | 322 |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
323 if (cp == NULL) abort (); |
9907 | 324 |
325 memset (&start, 0, sizeof (start)); | |
326 start.cb = sizeof (start); | |
327 | |
13425
b6eacb7da9f6
[HAVE_NTGUI] (create_child): Pass handles to children.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12325
diff
changeset
|
328 #ifdef HAVE_NTGUI |
38022
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
329 if (NILP (Vw32_start_process_show_window) && !is_gui_app) |
16000
b5ecd5022991
(Vwin32_start_process_show_window): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15419
diff
changeset
|
330 start.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; |
b5ecd5022991
(Vwin32_start_process_show_window): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15419
diff
changeset
|
331 else |
b5ecd5022991
(Vwin32_start_process_show_window): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15419
diff
changeset
|
332 start.dwFlags = STARTF_USESTDHANDLES; |
13425
b6eacb7da9f6
[HAVE_NTGUI] (create_child): Pass handles to children.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12325
diff
changeset
|
333 start.wShowWindow = SW_HIDE; |
b6eacb7da9f6
[HAVE_NTGUI] (create_child): Pass handles to children.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12325
diff
changeset
|
334 |
b6eacb7da9f6
[HAVE_NTGUI] (create_child): Pass handles to children.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12325
diff
changeset
|
335 start.hStdInput = GetStdHandle (STD_INPUT_HANDLE); |
b6eacb7da9f6
[HAVE_NTGUI] (create_child): Pass handles to children.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12325
diff
changeset
|
336 start.hStdOutput = GetStdHandle (STD_OUTPUT_HANDLE); |
b6eacb7da9f6
[HAVE_NTGUI] (create_child): Pass handles to children.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12325
diff
changeset
|
337 start.hStdError = GetStdHandle (STD_ERROR_HANDLE); |
b6eacb7da9f6
[HAVE_NTGUI] (create_child): Pass handles to children.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12325
diff
changeset
|
338 #endif /* HAVE_NTGUI */ |
b6eacb7da9f6
[HAVE_NTGUI] (create_child): Pass handles to children.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12325
diff
changeset
|
339 |
31115
42753ce203f8
(IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents:
26526
diff
changeset
|
340 #if 0 |
9907 | 341 /* Explicitly specify no security */ |
342 if (!InitializeSecurityDescriptor (&sec_desc, SECURITY_DESCRIPTOR_REVISION)) | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
343 goto EH_Fail; |
9907 | 344 if (!SetSecurityDescriptorDacl (&sec_desc, TRUE, NULL, FALSE)) |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
345 goto EH_Fail; |
31115
42753ce203f8
(IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents:
26526
diff
changeset
|
346 #endif |
9907 | 347 sec_attrs.nLength = sizeof (sec_attrs); |
31115
42753ce203f8
(IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents:
26526
diff
changeset
|
348 sec_attrs.lpSecurityDescriptor = NULL /* &sec_desc */; |
9907 | 349 sec_attrs.bInheritHandle = FALSE; |
350 | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
351 strcpy (dir, process_dir); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
352 unixtodos_filename (dir); |
23949
9f8417cca07b
(Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents:
23678
diff
changeset
|
353 |
9f8417cca07b
(Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents:
23678
diff
changeset
|
354 flags = (!NILP (Vw32_start_process_share_console) |
9f8417cca07b
(Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents:
23678
diff
changeset
|
355 ? CREATE_NEW_PROCESS_GROUP |
9f8417cca07b
(Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents:
23678
diff
changeset
|
356 : CREATE_NEW_CONSOLE); |
9f8417cca07b
(Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents:
23678
diff
changeset
|
357 if (NILP (Vw32_start_process_inherit_error_mode)) |
9f8417cca07b
(Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents:
23678
diff
changeset
|
358 flags |= CREATE_DEFAULT_ERROR_MODE; |
9907 | 359 if (!CreateProcess (exe, cmdline, &sec_attrs, NULL, TRUE, |
23949
9f8417cca07b
(Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents:
23678
diff
changeset
|
360 flags, env, dir, &start, &cp->procinfo)) |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
361 goto EH_Fail; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
362 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
363 cp->pid = (int) cp->procinfo.dwProcessId; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
364 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
365 /* Hack for Windows 95, which assigns large (ie negative) pids */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
366 if (cp->pid < 0) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
367 cp->pid = -cp->pid; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
368 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
369 /* pid must fit in a Lisp_Int */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
370 cp->pid = (cp->pid & VALMASK); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
371 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
372 *pPid = cp->pid; |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
373 |
9907 | 374 return TRUE; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
375 |
9907 | 376 EH_Fail: |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
377 DebPrint (("create_child.CreateProcess failed: %ld\n", GetLastError());); |
9907 | 378 return FALSE; |
379 } | |
380 | |
381 /* create_child doesn't know what emacs' file handle will be for waiting | |
382 on output from the child, so we need to make this additional call | |
383 to register the handle with the process | |
384 This way the select emulator knows how to match file handles with | |
385 entries in child_procs. */ | |
386 void | |
387 register_child (int pid, int fd) | |
388 { | |
389 child_process *cp; | |
390 | |
391 cp = find_child_pid (pid); | |
392 if (cp == NULL) | |
393 { | |
394 DebPrint (("register_child unable to find pid %lu\n", pid)); | |
395 return; | |
396 } | |
397 | |
398 #ifdef FULL_DEBUG | |
399 DebPrint (("register_child registered fd %d with pid %lu\n", fd, pid)); | |
400 #endif | |
401 | |
402 cp->fd = fd; | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
403 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
404 /* thread is initially blocked until select is called; set status so |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
405 that select will release thread */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
406 cp->status = STATUS_READ_ACKNOWLEDGED; |
9907 | 407 |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
408 /* attach child_process to fd_info */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
409 if (fd_info[fd].cp != NULL) |
9907 | 410 { |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
411 DebPrint (("register_child: fd_info[%d] apparently in use!\n", fd)); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
412 abort (); |
9907 | 413 } |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
414 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
415 fd_info[fd].cp = cp; |
9907 | 416 } |
417 | |
418 /* When a process dies its pipe will break so the reader thread will | |
419 signal failure to the select emulator. | |
420 The select emulator then calls this routine to clean up. | |
421 Since the thread signaled failure we can assume it is exiting. */ | |
422 static void | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
423 reap_subprocess (child_process *cp) |
9907 | 424 { |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
425 if (cp->procinfo.hProcess) |
9907 | 426 { |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
427 /* Reap the process */ |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
428 #ifdef FULL_DEBUG |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
429 /* Process should have already died before we are called. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
430 if (WaitForSingleObject (cp->procinfo.hProcess, 0) != WAIT_OBJECT_0) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
431 DebPrint (("reap_subprocess: child fpr fd %d has not died yet!", cp->fd)); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
432 #endif |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
433 CloseHandle (cp->procinfo.hProcess); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
434 cp->procinfo.hProcess = NULL; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
435 CloseHandle (cp->procinfo.hThread); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
436 cp->procinfo.hThread = NULL; |
9907 | 437 } |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
438 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
439 /* For asynchronous children, the child_proc resources will be freed |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
440 when the last pipe read descriptor is closed; for synchronous |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
441 children, we must explicitly free the resources now because |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
442 register_child has not been called. */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
443 if (cp->fd == -1) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
444 delete_child (cp); |
9907 | 445 } |
446 | |
447 /* Wait for any of our existing child processes to die | |
448 When it does, close its handle | |
449 Return the pid and fill in the status if non-NULL. */ | |
11388
96fa39ad9403
(win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
450 |
9907 | 451 int |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
452 sys_wait (int *status) |
9907 | 453 { |
454 DWORD active, retval; | |
455 int nh; | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
456 int pid; |
9907 | 457 child_process *cp, *cps[MAX_CHILDREN]; |
458 HANDLE wait_hnd[MAX_CHILDREN]; | |
459 | |
460 nh = 0; | |
461 if (dead_child != NULL) | |
462 { | |
463 /* We want to wait for a specific child */ | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
464 wait_hnd[nh] = dead_child->procinfo.hProcess; |
9907 | 465 cps[nh] = dead_child; |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
466 if (!wait_hnd[nh]) abort (); |
9907 | 467 nh++; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
468 active = 0; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
469 goto get_result; |
9907 | 470 } |
471 else | |
472 { | |
473 for (cp = child_procs+(child_proc_count-1); cp >= child_procs; cp--) | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
474 /* some child_procs might be sockets; ignore them */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
475 if (CHILD_ACTIVE (cp) && cp->procinfo.hProcess) |
9907 | 476 { |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
477 wait_hnd[nh] = cp->procinfo.hProcess; |
9907 | 478 cps[nh] = cp; |
479 nh++; | |
480 } | |
481 } | |
482 | |
483 if (nh == 0) | |
484 { | |
485 /* Nothing to wait on, so fail */ | |
486 errno = ECHILD; | |
487 return -1; | |
488 } | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
489 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
490 do |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
491 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
492 /* Check for quit about once a second. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
493 QUIT; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
494 active = WaitForMultipleObjects (nh, wait_hnd, FALSE, 1000); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
495 } while (active == WAIT_TIMEOUT); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
496 |
9907 | 497 if (active == WAIT_FAILED) |
498 { | |
499 errno = EBADF; | |
500 return -1; | |
501 } | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
502 else if (active >= WAIT_OBJECT_0 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
503 && active < WAIT_OBJECT_0+MAXIMUM_WAIT_OBJECTS) |
9907 | 504 { |
505 active -= WAIT_OBJECT_0; | |
506 } | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
507 else if (active >= WAIT_ABANDONED_0 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
508 && active < WAIT_ABANDONED_0+MAXIMUM_WAIT_OBJECTS) |
9907 | 509 { |
510 active -= WAIT_ABANDONED_0; | |
511 } | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
512 else |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
513 abort (); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
514 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
515 get_result: |
9907 | 516 if (!GetExitCodeProcess (wait_hnd[active], &retval)) |
517 { | |
518 DebPrint (("Wait.GetExitCodeProcess failed with %lu\n", | |
519 GetLastError ())); | |
520 retval = 1; | |
521 } | |
522 if (retval == STILL_ACTIVE) | |
523 { | |
524 /* Should never happen */ | |
525 DebPrint (("Wait.WaitForMultipleObjects returned an active process\n")); | |
526 errno = EINVAL; | |
527 return -1; | |
528 } | |
12325
aa6fc4e97a28
(win32_wait): Massage retval into what is expected in Unix.
Richard M. Stallman <rms@gnu.org>
parents:
12239
diff
changeset
|
529 |
aa6fc4e97a28
(win32_wait): Massage retval into what is expected in Unix.
Richard M. Stallman <rms@gnu.org>
parents:
12239
diff
changeset
|
530 /* Massage the exit code from the process to match the format expected |
14036 | 531 by the WIFSTOPPED et al macros in syswait.h. Only WIFSIGNALED and |
12325
aa6fc4e97a28
(win32_wait): Massage retval into what is expected in Unix.
Richard M. Stallman <rms@gnu.org>
parents:
12239
diff
changeset
|
532 WIFEXITED are supported; WIFSTOPPED doesn't make sense under NT. */ |
aa6fc4e97a28
(win32_wait): Massage retval into what is expected in Unix.
Richard M. Stallman <rms@gnu.org>
parents:
12239
diff
changeset
|
533 |
aa6fc4e97a28
(win32_wait): Massage retval into what is expected in Unix.
Richard M. Stallman <rms@gnu.org>
parents:
12239
diff
changeset
|
534 if (retval == STATUS_CONTROL_C_EXIT) |
aa6fc4e97a28
(win32_wait): Massage retval into what is expected in Unix.
Richard M. Stallman <rms@gnu.org>
parents:
12239
diff
changeset
|
535 retval = SIGINT; |
aa6fc4e97a28
(win32_wait): Massage retval into what is expected in Unix.
Richard M. Stallman <rms@gnu.org>
parents:
12239
diff
changeset
|
536 else |
aa6fc4e97a28
(win32_wait): Massage retval into what is expected in Unix.
Richard M. Stallman <rms@gnu.org>
parents:
12239
diff
changeset
|
537 retval <<= 8; |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
538 |
9907 | 539 cp = cps[active]; |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
540 pid = cp->pid; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
541 #ifdef FULL_DEBUG |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
542 DebPrint (("Wait signaled with process pid %d\n", cp->pid)); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
543 #endif |
11388
96fa39ad9403
(win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
544 |
9907 | 545 if (status) |
546 { | |
11388
96fa39ad9403
(win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
547 *status = retval; |
96fa39ad9403
(win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
548 } |
96fa39ad9403
(win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
549 else if (synch_process_alive) |
96fa39ad9403
(win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
550 { |
96fa39ad9403
(win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
551 synch_process_alive = 0; |
96fa39ad9403
(win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
552 |
13931
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
553 /* Report the status of the synchronous process. */ |
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
554 if (WIFEXITED (retval)) |
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
555 synch_process_retcode = WRETCODE (retval); |
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
556 else if (WIFSIGNALED (retval)) |
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
557 { |
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
558 int code = WTERMSIG (retval); |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25646
diff
changeset
|
559 char *signame; |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25646
diff
changeset
|
560 |
26526
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
561 synchronize_system_messages_locale (); |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25646
diff
changeset
|
562 signame = strsignal (code); |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25646
diff
changeset
|
563 |
13931
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
564 if (signame == 0) |
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
565 signame = "unknown"; |
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
566 |
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
567 synch_process_death = signame; |
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
568 } |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
569 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
570 reap_subprocess (cp); |
9907 | 571 } |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
572 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
573 reap_subprocess (cp); |
9907 | 574 |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
575 return pid; |
9907 | 576 } |
577 | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
578 void |
38022
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
579 w32_executable_type (char * filename, int * is_dos_app, int * is_cygnus_app, int * is_gui_app) |
15247
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
580 { |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
581 file_data executable; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
582 char * p; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
583 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
584 /* Default values in case we can't tell for sure. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
585 *is_dos_app = FALSE; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
586 *is_cygnus_app = FALSE; |
38022
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
587 *is_gui_app = FALSE; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
588 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
589 if (!open_input_file (&executable, filename)) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
590 return; |
15247
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
591 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
592 p = strrchr (filename, '.'); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
593 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
594 /* We can only identify DOS .com programs from the extension. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
595 if (p && stricmp (p, ".com") == 0) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
596 *is_dos_app = TRUE; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
597 else if (p && (stricmp (p, ".bat") == 0 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
598 || stricmp (p, ".cmd") == 0)) |
15247
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
599 { |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
600 /* A DOS shell script - it appears that CreateProcess is happy to |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
601 accept this (somewhat surprisingly); presumably it looks at |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
602 COMSPEC to determine what executable to actually invoke. |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
603 Therefore, we have to do the same here as well. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
604 /* Actually, I think it uses the program association for that |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
605 extension, which is defined in the registry. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
606 p = egetenv ("COMSPEC"); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
607 if (p) |
38022
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
608 w32_executable_type (p, is_dos_app, is_cygnus_app, is_gui_app); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
609 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
610 else |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
611 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
612 /* Look for DOS .exe signature - if found, we must also check that |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
613 it isn't really a 16- or 32-bit Windows exe, since both formats |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
614 start with a DOS program stub. Note that 16-bit Windows |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
615 executables use the OS/2 1.x format. */ |
15247
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
616 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
617 IMAGE_DOS_HEADER * dos_header; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
618 IMAGE_NT_HEADERS * nt_header; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
619 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
620 dos_header = (PIMAGE_DOS_HEADER) executable.file_base; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
621 if (dos_header->e_magic != IMAGE_DOS_SIGNATURE) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
622 goto unwind; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
623 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
624 nt_header = (PIMAGE_NT_HEADERS) ((char *) dos_header + dos_header->e_lfanew); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
625 |
21613
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
626 if ((char *) nt_header > (char *) dos_header + executable.size) |
15247
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
627 { |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
628 /* Some dos headers (pkunzip) have bogus e_lfanew fields. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
629 *is_dos_app = TRUE; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
630 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
631 else if (nt_header->Signature != IMAGE_NT_SIGNATURE |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
632 && LOWORD (nt_header->Signature) != IMAGE_OS2_SIGNATURE) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
633 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
634 *is_dos_app = TRUE; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
635 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
636 else if (nt_header->Signature == IMAGE_NT_SIGNATURE) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
637 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
638 /* Look for cygwin.dll in DLL import list. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
639 IMAGE_DATA_DIRECTORY import_dir = |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
640 nt_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT]; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
641 IMAGE_IMPORT_DESCRIPTOR * imports; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
642 IMAGE_SECTION_HEADER * section; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
643 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
644 section = rva_to_section (import_dir.VirtualAddress, nt_header); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
645 imports = RVA_TO_PTR (import_dir.VirtualAddress, section, executable); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
646 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
647 for ( ; imports->Name; imports++) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
648 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
649 char * dllname = RVA_TO_PTR (imports->Name, section, executable); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
650 |
24105
6252c59e8b6c
(w32_executable_type): Relax the check to identify
Andrew Innes <andrewi@gnu.org>
parents:
23949
diff
changeset
|
651 /* The exact name of the cygwin dll has changed with |
6252c59e8b6c
(w32_executable_type): Relax the check to identify
Andrew Innes <andrewi@gnu.org>
parents:
23949
diff
changeset
|
652 various releases, but hopefully this will be reasonably |
6252c59e8b6c
(w32_executable_type): Relax the check to identify
Andrew Innes <andrewi@gnu.org>
parents:
23949
diff
changeset
|
653 future proof. */ |
6252c59e8b6c
(w32_executable_type): Relax the check to identify
Andrew Innes <andrewi@gnu.org>
parents:
23949
diff
changeset
|
654 if (strncmp (dllname, "cygwin", 6) == 0) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
655 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
656 *is_cygnus_app = TRUE; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
657 break; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
658 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
659 } |
38022
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
660 |
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
661 /* Check whether app is marked as a console or windowed (aka |
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
662 GUI) app. Accept Posix and OS2 subsytem apps as console |
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
663 apps. */ |
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
664 *is_gui_app = (nt_header->OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
665 } |
15247
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
666 } |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
667 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
668 unwind: |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
669 close_file_data (&executable); |
15247
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
670 } |
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
671 |
16826
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
672 int |
31115
42753ce203f8
(IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents:
26526
diff
changeset
|
673 compare_env (const void *strp1, const void *strp2) |
16826
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
674 { |
31115
42753ce203f8
(IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents:
26526
diff
changeset
|
675 const char *str1 = *(const char **)strp1, *str2 = *(const char **)strp2; |
16826
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
676 |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
677 while (*str1 && *str2 && *str1 != '=' && *str2 != '=') |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
678 { |
31354
547138676a74
(compare_env): Convert to uppercase for comparison,
Andrew Innes <andrewi@gnu.org>
parents:
31115
diff
changeset
|
679 /* Sort order in command.com/cmd.exe is based on uppercasing |
547138676a74
(compare_env): Convert to uppercase for comparison,
Andrew Innes <andrewi@gnu.org>
parents:
31115
diff
changeset
|
680 names, so do the same here. */ |
547138676a74
(compare_env): Convert to uppercase for comparison,
Andrew Innes <andrewi@gnu.org>
parents:
31115
diff
changeset
|
681 if (toupper (*str1) > toupper (*str2)) |
16826
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
682 return 1; |
31354
547138676a74
(compare_env): Convert to uppercase for comparison,
Andrew Innes <andrewi@gnu.org>
parents:
31115
diff
changeset
|
683 else if (toupper (*str1) < toupper (*str2)) |
16826
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
684 return -1; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
685 str1++, str2++; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
686 } |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
687 |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
688 if (*str1 == '=' && *str2 == '=') |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
689 return 0; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
690 else if (*str1 == '=') |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
691 return -1; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
692 else |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
693 return 1; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
694 } |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
695 |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
696 void |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
697 merge_and_sort_env (char **envp1, char **envp2, char **new_envp) |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
698 { |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
699 char **optr, **nptr; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
700 int num; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
701 |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
702 nptr = new_envp; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
703 optr = envp1; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
704 while (*optr) |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
705 *nptr++ = *optr++; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
706 num = optr - envp1; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
707 |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
708 optr = envp2; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
709 while (*optr) |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
710 *nptr++ = *optr++; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
711 num += optr - envp2; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
712 |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
713 qsort (new_envp, num, sizeof (char *), compare_env); |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
714 |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
715 *nptr = NULL; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
716 } |
9907 | 717 |
718 /* When a new child process is created we need to register it in our list, | |
719 so intercept spawn requests. */ | |
720 int | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
721 sys_spawnve (int mode, char *cmdname, char **argv, char **envp) |
9907 | 722 { |
12239
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
723 Lisp_Object program, full; |
9907 | 724 char *cmdline, *env, *parg, **targ; |
16826
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
725 int arglen, numenv; |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
726 int pid; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
727 child_process *cp; |
38022
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
728 int is_dos_app, is_cygnus_app, is_gui_app; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
729 int do_quoting = 0; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
730 char escape_char; |
16826
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
731 /* We pass our process ID to our children by setting up an environment |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
732 variable in their environment. */ |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
733 char ppid_env_var_buffer[64]; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
734 char *extra_env[] = {ppid_env_var_buffer, NULL}; |
37290
6e6e46d239df
(sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents:
33694
diff
changeset
|
735 char *sepchars = " \t"; |
16826
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
736 |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
737 /* We don't care about the other modes */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
738 if (mode != _P_NOWAIT) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
739 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
740 errno = EINVAL; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
741 return -1; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
742 } |
12239
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
743 |
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
744 /* Handle executable names without an executable suffix. */ |
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
745 program = make_string (cmdname, strlen (cmdname)); |
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
746 if (NILP (Ffile_executable_p (program))) |
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
747 { |
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
748 struct gcpro gcpro1; |
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
749 |
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
750 full = Qnil; |
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
751 GCPRO1 (program); |
45008
07245ba4ebcc
(sys_spawnve): Update call to openp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44928
diff
changeset
|
752 openp (Vexec_path, program, Vexec_suffixes, &full, make_number (X_OK)); |
12239
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
753 UNGCPRO; |
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
754 if (NILP (full)) |
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
755 { |
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
756 errno = EINVAL; |
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
757 return -1; |
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
758 } |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
759 program = full; |
12239
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
760 } |
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
761 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
762 /* make sure argv[0] and cmdname are both in DOS format */ |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45089
diff
changeset
|
763 cmdname = SDATA (program); |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
764 unixtodos_filename (cmdname); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
765 argv[0] = cmdname; |
15247
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
766 |
21613
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
767 /* Determine whether program is a 16-bit DOS executable, or a w32 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
768 executable that is implicitly linked to the Cygnus dll (implying it |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
769 was compiled with the Cygnus GNU toolchain and hence relies on |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
770 cygwin.dll to parse the command line - we use this to decide how to |
38022
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
771 escape quote chars in command line args that must be quoted). |
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
772 |
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
773 Also determine whether it is a GUI app, so that we don't hide its |
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
774 initial window unless specifically requested. */ |
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
775 w32_executable_type (cmdname, &is_dos_app, &is_cygnus_app, &is_gui_app); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
776 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
777 /* On Windows 95, if cmdname is a DOS app, we invoke a helper |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
778 application to start it by specifying the helper app as cmdname, |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
779 while leaving the real app name as argv[0]. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
780 if (is_dos_app) |
15247
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
781 { |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
782 cmdname = alloca (MAXPATHLEN); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
783 if (egetenv ("CMDPROXY")) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
784 strcpy (cmdname, egetenv ("CMDPROXY")); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
785 else |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
786 { |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45089
diff
changeset
|
787 strcpy (cmdname, SDATA (Vinvocation_directory)); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
788 strcat (cmdname, "cmdproxy.exe"); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
789 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
790 unixtodos_filename (cmdname); |
15247
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
791 } |
9907 | 792 |
793 /* we have to do some conjuring here to put argv and envp into the | |
794 form CreateProcess wants... argv needs to be a space separated/null | |
795 terminated list of parameters, and envp is a null | |
796 separated/double-null terminated list of parameters. | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
797 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
798 Additionally, zero-length args and args containing whitespace or |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
799 quote chars need to be wrapped in double quotes - for this to work, |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
800 embedded quotes need to be escaped as well. The aim is to ensure |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
801 the child process reconstructs the argv array we start with |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
802 exactly, so we treat quotes at the beginning and end of arguments |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
803 as embedded quotes. |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
804 |
21613
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
805 The w32 GNU-based library from Cygnus doubles quotes to escape |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
806 them, while MSVC uses backslash for escaping. (Actually the MSVC |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
807 startup code does attempt to recognise doubled quotes and accept |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
808 them, but gets it wrong and ends up requiring three quotes to get a |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
809 single embedded quote!) So by default we decide whether to use |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
810 quote or backslash as the escape character based on whether the |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
811 binary is apparently a Cygnus compiled app. |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
812 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
813 Note that using backslash to escape embedded quotes requires |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
814 additional special handling if an embedded quote is already |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
815 preceeded by backslash, or if an arg requiring quoting ends with |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
816 backslash. In such cases, the run of escape characters needs to be |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
817 doubled. For consistency, we apply this special handling as long |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
818 as the escape character is not quote. |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
819 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
820 Since we have no idea how large argv and envp are likely to be we |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
821 figure out list lengths on the fly and allocate them. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
822 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
823 if (!NILP (Vw32_quote_process_args)) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
824 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
825 do_quoting = 1; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
826 /* Override escape char by binding w32-quote-process-args to |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
827 desired character, or use t for auto-selection. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
828 if (INTEGERP (Vw32_quote_process_args)) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
829 escape_char = XINT (Vw32_quote_process_args); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
830 else |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
831 escape_char = is_cygnus_app ? '"' : '\\'; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
832 } |
9907 | 833 |
37290
6e6e46d239df
(sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents:
33694
diff
changeset
|
834 /* Cygwin apps needs quoting a bit more often */ |
6e6e46d239df
(sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents:
33694
diff
changeset
|
835 if (escape_char == '"') |
6e6e46d239df
(sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents:
33694
diff
changeset
|
836 sepchars = "\r\n\t\f '"; |
6e6e46d239df
(sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents:
33694
diff
changeset
|
837 |
9907 | 838 /* do argv... */ |
839 arglen = 0; | |
840 targ = argv; | |
841 while (*targ) | |
842 { | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
843 char * p = *targ; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
844 int need_quotes = 0; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
845 int escape_char_run = 0; |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
846 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
847 if (*p == 0) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
848 need_quotes = 1; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
849 for ( ; *p; p++) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
850 { |
37290
6e6e46d239df
(sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents:
33694
diff
changeset
|
851 if (escape_char == '"' && *p == '\\') |
6e6e46d239df
(sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents:
33694
diff
changeset
|
852 /* If it's a Cygwin app, \ needs to be escaped. */ |
6e6e46d239df
(sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents:
33694
diff
changeset
|
853 arglen++; |
6e6e46d239df
(sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents:
33694
diff
changeset
|
854 else if (*p == '"') |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
855 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
856 /* allow for embedded quotes to be escaped */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
857 arglen++; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
858 need_quotes = 1; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
859 /* handle the case where the embedded quote is already escaped */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
860 if (escape_char_run > 0) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
861 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
862 /* To preserve the arg exactly, we need to double the |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
863 preceding escape characters (plus adding one to |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
864 escape the quote character itself). */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
865 arglen += escape_char_run; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
866 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
867 } |
37290
6e6e46d239df
(sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents:
33694
diff
changeset
|
868 else if (strchr (sepchars, *p) != NULL) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
869 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
870 need_quotes = 1; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
871 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
872 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
873 if (*p == escape_char && escape_char != '"') |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
874 escape_char_run++; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
875 else |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
876 escape_char_run = 0; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
877 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
878 if (need_quotes) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
879 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
880 arglen += 2; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
881 /* handle the case where the arg ends with an escape char - we |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
882 must not let the enclosing quote be escaped. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
883 if (escape_char_run > 0) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
884 arglen += escape_char_run; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
885 } |
9907 | 886 arglen += strlen (*targ++) + 1; |
887 } | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
888 cmdline = alloca (arglen); |
9907 | 889 targ = argv; |
890 parg = cmdline; | |
891 while (*targ) | |
892 { | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
893 char * p = *targ; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
894 int need_quotes = 0; |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
895 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
896 if (*p == 0) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
897 need_quotes = 1; |
15201
43551ec4b69d
(Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15145
diff
changeset
|
898 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
899 if (do_quoting) |
15201
43551ec4b69d
(Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15145
diff
changeset
|
900 { |
43551ec4b69d
(Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15145
diff
changeset
|
901 for ( ; *p; p++) |
37290
6e6e46d239df
(sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents:
33694
diff
changeset
|
902 if ((strchr (sepchars, *p) != NULL) || *p == '"') |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
903 need_quotes = 1; |
15201
43551ec4b69d
(Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15145
diff
changeset
|
904 } |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
905 if (need_quotes) |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
906 { |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
907 int escape_char_run = 0; |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
908 char * first; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
909 char * last; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
910 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
911 p = *targ; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
912 first = p; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
913 last = p + strlen (p) - 1; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
914 *parg++ = '"'; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
915 #if 0 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
916 /* This version does not escape quotes if they occur at the |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
917 beginning or end of the arg - this could lead to incorrect |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
918 behaviour when the arg itself represents a command line |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
919 containing quoted args. I believe this was originally done |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
920 as a hack to make some things work, before |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
921 `w32-quote-process-args' was added. */ |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
922 while (*p) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
923 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
924 if (*p == '"' && p > first && p < last) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
925 *parg++ = escape_char; /* escape embedded quotes */ |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
926 *parg++ = *p++; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
927 } |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
928 #else |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
929 for ( ; *p; p++) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
930 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
931 if (*p == '"') |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
932 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
933 /* double preceding escape chars if any */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
934 while (escape_char_run > 0) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
935 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
936 *parg++ = escape_char; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
937 escape_char_run--; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
938 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
939 /* escape all quote chars, even at beginning or end */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
940 *parg++ = escape_char; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
941 } |
37290
6e6e46d239df
(sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents:
33694
diff
changeset
|
942 else if (escape_char == '"' && *p == '\\') |
6e6e46d239df
(sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents:
33694
diff
changeset
|
943 *parg++ = '\\'; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
944 *parg++ = *p; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
945 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
946 if (*p == escape_char && escape_char != '"') |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
947 escape_char_run++; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
948 else |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
949 escape_char_run = 0; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
950 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
951 /* double escape chars before enclosing quote */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
952 while (escape_char_run > 0) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
953 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
954 *parg++ = escape_char; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
955 escape_char_run--; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
956 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
957 #endif |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
958 *parg++ = '"'; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
959 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
960 else |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
961 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
962 strcpy (parg, *targ); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
963 parg += strlen (*targ); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
964 } |
9907 | 965 *parg++ = ' '; |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
966 targ++; |
9907 | 967 } |
968 *--parg = '\0'; | |
969 | |
970 /* and envp... */ | |
971 arglen = 1; | |
972 targ = envp; | |
16826
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
973 numenv = 1; /* for end null */ |
9907 | 974 while (*targ) |
975 { | |
976 arglen += strlen (*targ++) + 1; | |
16826
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
977 numenv++; |
9907 | 978 } |
16826
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
979 /* extra env vars... */ |
22298
e509b80a17a2
(sys_spawnve): Place Emacs pid in EM_PARENT_PROCESS_ID.
Geoff Voelker <voelker@cs.washington.edu>
parents:
22079
diff
changeset
|
980 sprintf (ppid_env_var_buffer, "EM_PARENT_PROCESS_ID=%d", |
9907 | 981 GetCurrentProcessId ()); |
982 arglen += strlen (ppid_env_var_buffer) + 1; | |
16826
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
983 numenv++; |
9907 | 984 |
16826
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
985 /* merge env passed in and extra env into one, and sort it. */ |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
986 targ = (char **) alloca (numenv * sizeof (char *)); |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
987 merge_and_sort_env (envp, extra_env, targ); |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
988 |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
989 /* concatenate env entries. */ |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
990 env = alloca (arglen); |
9907 | 991 parg = env; |
992 while (*targ) | |
993 { | |
994 strcpy (parg, *targ); | |
995 parg += strlen (*targ++); | |
996 *parg++ = '\0'; | |
997 } | |
998 *parg++ = '\0'; | |
999 *parg = '\0'; | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1000 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1001 cp = new_child (); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1002 if (cp == NULL) |
9907 | 1003 { |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1004 errno = EAGAIN; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1005 return -1; |
9907 | 1006 } |
1007 | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1008 /* Now create the process. */ |
38022
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
1009 if (!create_child (cmdname, cmdline, env, is_gui_app, &pid, cp)) |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1010 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1011 delete_child (cp); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1012 errno = ENOEXEC; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1013 return -1; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1014 } |
9907 | 1015 |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1016 return pid; |
9907 | 1017 } |
1018 | |
1019 /* Emulate the select call | |
1020 Wait for available input on any of the given rfds, or timeout if | |
1021 a timeout is given and no input is detected | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1022 wfds and efds are not supported and must be NULL. |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1023 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1024 For simplicity, we detect the death of child processes here and |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1025 synchronously call the SIGCHLD handler. Since it is possible for |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1026 children to be created without a corresponding pipe handle from which |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1027 to read output, we wait separately on the process handles as well as |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1028 the char_avail events for each process pipe. We only call |
22079
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1029 wait/reap_process when the process actually terminates. |
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1030 |
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1031 To reduce the number of places in which Emacs can be hung such that |
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1032 C-g is not able to interrupt it, we always wait on interrupt_handle |
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1033 (which is signalled by the input thread when C-g is detected). If we |
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1034 detect that we were woken up by C-g, we return -1 with errno set to |
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1035 EINTR as on Unix. */ |
9907 | 1036 |
1037 /* From ntterm.c */ | |
1038 extern HANDLE keyboard_handle; | |
22079
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1039 |
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1040 /* From w32xfns.c */ |
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1041 extern HANDLE interrupt_handle; |
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1042 |
9907 | 1043 /* From process.c */ |
1044 extern int proc_buffered_char[]; | |
1045 | |
1046 int | |
11388
96fa39ad9403
(win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
1047 sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, |
96fa39ad9403
(win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
1048 EMACS_TIME *timeout) |
9907 | 1049 { |
1050 SELECT_TYPE orfds; | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1051 DWORD timeout_ms, start_time; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1052 int i, nh, nc, nr; |
9907 | 1053 DWORD active; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1054 child_process *cp, *cps[MAX_CHILDREN]; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1055 HANDLE wait_hnd[MAXDESC + MAX_CHILDREN]; |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1056 int fdindex[MAXDESC]; /* mapping from wait handles back to descriptors */ |
9907 | 1057 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1058 timeout_ms = timeout ? (timeout->tv_sec * 1000 + timeout->tv_usec / 1000) : INFINITE; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1059 |
9907 | 1060 /* If the descriptor sets are NULL but timeout isn't, then just Sleep. */ |
1061 if (rfds == NULL && wfds == NULL && efds == NULL && timeout != NULL) | |
1062 { | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1063 Sleep (timeout_ms); |
9907 | 1064 return 0; |
1065 } | |
1066 | |
1067 /* Otherwise, we only handle rfds, so fail otherwise. */ | |
1068 if (rfds == NULL || wfds != NULL || efds != NULL) | |
1069 { | |
1070 errno = EINVAL; | |
1071 return -1; | |
1072 } | |
1073 | |
1074 orfds = *rfds; | |
1075 FD_ZERO (rfds); | |
1076 nr = 0; | |
22079
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1077 |
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1078 /* Always wait on interrupt_handle, to detect C-g (quit). */ |
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1079 wait_hnd[0] = interrupt_handle; |
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1080 fdindex[0] = -1; |
9907 | 1081 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1082 /* Build a list of pipe handles to wait on. */ |
22079
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1083 nh = 1; |
9907 | 1084 for (i = 0; i < nfds; i++) |
1085 if (FD_ISSET (i, &orfds)) | |
1086 { | |
1087 if (i == 0) | |
1088 { | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1089 if (keyboard_handle) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1090 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1091 /* Handle stdin specially */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1092 wait_hnd[nh] = keyboard_handle; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1093 fdindex[nh] = i; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1094 nh++; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1095 } |
9907 | 1096 |
1097 /* Check for any emacs-generated input in the queue since | |
1098 it won't be detected in the wait */ | |
1099 if (detect_input_pending ()) | |
1100 { | |
1101 FD_SET (i, rfds); | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1102 return 1; |
9907 | 1103 } |
1104 } | |
1105 else | |
1106 { | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1107 /* Child process and socket input */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1108 cp = fd_info[i].cp; |
9907 | 1109 if (cp) |
1110 { | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1111 int current_status = cp->status; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1112 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1113 if (current_status == STATUS_READ_ACKNOWLEDGED) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1114 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1115 /* Tell reader thread which file handle to use. */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1116 cp->fd = i; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1117 /* Wake up the reader thread for this process */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1118 cp->status = STATUS_READ_READY; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1119 if (!SetEvent (cp->char_consumed)) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1120 DebPrint (("nt_select.SetEvent failed with " |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1121 "%lu for fd %ld\n", GetLastError (), i)); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1122 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1123 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1124 #ifdef CHECK_INTERLOCK |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1125 /* slightly crude cross-checking of interlock between threads */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1126 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1127 current_status = cp->status; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1128 if (WaitForSingleObject (cp->char_avail, 0) == WAIT_OBJECT_0) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1129 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1130 /* char_avail has been signalled, so status (which may |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1131 have changed) should indicate read has completed |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1132 but has not been acknowledged. */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1133 current_status = cp->status; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1134 if (current_status != STATUS_READ_SUCCEEDED |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1135 && current_status != STATUS_READ_FAILED) |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1136 DebPrint (("char_avail set, but read not completed: status %d\n", |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1137 current_status)); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1138 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1139 else |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1140 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1141 /* char_avail has not been signalled, so status should |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1142 indicate that read is in progress; small possibility |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1143 that read has completed but event wasn't yet signalled |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1144 when we tested it (because a context switch occurred |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1145 or if running on separate CPUs). */ |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1146 if (current_status != STATUS_READ_READY |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1147 && current_status != STATUS_READ_IN_PROGRESS |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1148 && current_status != STATUS_READ_SUCCEEDED |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1149 && current_status != STATUS_READ_FAILED) |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1150 DebPrint (("char_avail reset, but read status is bad: %d\n", |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1151 current_status)); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1152 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1153 #endif |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1154 wait_hnd[nh] = cp->char_avail; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1155 fdindex[nh] = i; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1156 if (!wait_hnd[nh]) abort (); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1157 nh++; |
9907 | 1158 #ifdef FULL_DEBUG |
1159 DebPrint (("select waiting on child %d fd %d\n", | |
1160 cp-child_procs, i)); | |
1161 #endif | |
1162 } | |
1163 else | |
1164 { | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1165 /* Unable to find something to wait on for this fd, skip */ |
21613
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1166 |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1167 /* Note that this is not a fatal error, and can in fact |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1168 happen in unusual circumstances. Specifically, if |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1169 sys_spawnve fails, eg. because the program doesn't |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1170 exist, and debug-on-error is t so Fsignal invokes a |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1171 nested input loop, then the process output pipe is |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1172 still included in input_wait_mask with no child_proc |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1173 associated with it. (It is removed when the debugger |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1174 exits the nested input loop and the error is thrown.) */ |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1175 |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1176 DebPrint (("sys_select: fd %ld is invalid! ignoring\n", i)); |
9907 | 1177 } |
1178 } | |
1179 } | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1180 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1181 count_children: |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1182 /* Add handles of child processes. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1183 nc = 0; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1184 for (cp = child_procs+(child_proc_count-1); cp >= child_procs; cp--) |
21613
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1185 /* Some child_procs might be sockets; ignore them. Also some |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1186 children may have died already, but we haven't finished reading |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1187 the process output; ignore them too. */ |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1188 if (CHILD_ACTIVE (cp) && cp->procinfo.hProcess |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1189 && (cp->fd < 0 |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1190 || (fd_info[cp->fd].flags & FILE_SEND_SIGCHLD) == 0 |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1191 || (fd_info[cp->fd].flags & FILE_AT_EOF) != 0) |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1192 ) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1193 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1194 wait_hnd[nh + nc] = cp->procinfo.hProcess; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1195 cps[nc] = cp; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1196 nc++; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1197 } |
9907 | 1198 |
1199 /* Nothing to look for, so we didn't find anything */ | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1200 if (nh + nc == 0) |
9907 | 1201 { |
11388
96fa39ad9403
(win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
1202 if (timeout) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1203 Sleep (timeout_ms); |
9907 | 1204 return 0; |
1205 } | |
1206 | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1207 start_time = GetTickCount (); |
24915
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1208 |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1209 /* Wait for input or child death to be signalled. If user input is |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1210 allowed, then also accept window messages. */ |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1211 if (FD_ISSET (0, &orfds)) |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1212 active = MsgWaitForMultipleObjects (nh + nc, wait_hnd, FALSE, timeout_ms, |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1213 QS_ALLINPUT); |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1214 else |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1215 active = WaitForMultipleObjects (nh + nc, wait_hnd, FALSE, timeout_ms); |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1216 |
9907 | 1217 if (active == WAIT_FAILED) |
1218 { | |
1219 DebPrint (("select.WaitForMultipleObjects (%d, %lu) failed with %lu\n", | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1220 nh + nc, timeout_ms, GetLastError ())); |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1221 /* don't return EBADF - this causes wait_reading_process_input to |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1222 abort; WAIT_FAILED is returned when single-stepping under |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1223 Windows 95 after switching thread focus in debugger, and |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1224 possibly at other times. */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1225 errno = EINTR; |
9907 | 1226 return -1; |
1227 } | |
1228 else if (active == WAIT_TIMEOUT) | |
1229 { | |
1230 return 0; | |
1231 } | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1232 else if (active >= WAIT_OBJECT_0 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1233 && active < WAIT_OBJECT_0+MAXIMUM_WAIT_OBJECTS) |
9907 | 1234 { |
1235 active -= WAIT_OBJECT_0; | |
1236 } | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1237 else if (active >= WAIT_ABANDONED_0 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1238 && active < WAIT_ABANDONED_0+MAXIMUM_WAIT_OBJECTS) |
9907 | 1239 { |
1240 active -= WAIT_ABANDONED_0; | |
1241 } | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1242 else |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1243 abort (); |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1244 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1245 /* Loop over all handles after active (now officially documented as |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1246 being the first signalled handle in the array). We do this to |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1247 ensure fairness, so that all channels with data available will be |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1248 processed - otherwise higher numbered channels could be starved. */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1249 do |
9907 | 1250 { |
24915
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1251 if (active == nh + nc) |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1252 { |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1253 /* There are messages in the lisp thread's queue; we must |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1254 drain the queue now to ensure they are processed promptly, |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1255 because if we don't do so, we will not be woken again until |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1256 further messages arrive. |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1257 |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1258 NB. If ever we allow window message procedures to callback |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1259 into lisp, we will need to ensure messages are dispatched |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1260 at a safe time for lisp code to be run (*), and we may also |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1261 want to provide some hooks in the dispatch loop to cater |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1262 for modeless dialogs created by lisp (ie. to register |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1263 window handles to pass to IsDialogMessage). |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1264 |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1265 (*) Note that MsgWaitForMultipleObjects above is an |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1266 internal dispatch point for messages that are sent to |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1267 windows created by this thread. */ |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1268 drain_message_queue (); |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1269 } |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1270 else if (active >= nh) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1271 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1272 cp = cps[active - nh]; |
21613
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1273 |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1274 /* We cannot always signal SIGCHLD immediately; if we have not |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1275 finished reading the process output, we must delay sending |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1276 SIGCHLD until we do. */ |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1277 |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1278 if (cp->fd >= 0 && (fd_info[cp->fd].flags & FILE_AT_EOF) == 0) |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1279 fd_info[cp->fd].flags |= FILE_SEND_SIGCHLD; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1280 /* SIG_DFL for SIGCHLD is ignore */ |
21613
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1281 else if (sig_handlers[SIGCHLD] != SIG_DFL && |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1282 sig_handlers[SIGCHLD] != SIG_IGN) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1283 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1284 #ifdef FULL_DEBUG |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1285 DebPrint (("select calling SIGCHLD handler for pid %d\n", |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1286 cp->pid)); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1287 #endif |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1288 dead_child = cp; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1289 sig_handlers[SIGCHLD] (SIGCHLD); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1290 dead_child = NULL; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1291 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1292 } |
22079
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1293 else if (fdindex[active] == -1) |
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1294 { |
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1295 /* Quit (C-g) was detected. */ |
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1296 errno = EINTR; |
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1297 return -1; |
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1298 } |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1299 else if (fdindex[active] == 0) |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1300 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1301 /* Keyboard input available */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1302 FD_SET (0, rfds); |
9907 | 1303 nr++; |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1304 } |
9907 | 1305 else |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1306 { |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1307 /* must be a socket or pipe - read ahead should have |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1308 completed, either succeeding or failing. */ |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1309 FD_SET (fdindex[active], rfds); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1310 nr++; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1311 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1312 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1313 /* Even though wait_reading_process_output only reads from at most |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1314 one channel, we must process all channels here so that we reap |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1315 all children that have died. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1316 while (++active < nh + nc) |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1317 if (WaitForSingleObject (wait_hnd[active], 0) == WAIT_OBJECT_0) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1318 break; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1319 } while (active < nh + nc); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1320 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1321 /* If no input has arrived and timeout hasn't expired, wait again. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1322 if (nr == 0) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1323 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1324 DWORD elapsed = GetTickCount () - start_time; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1325 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1326 if (timeout_ms > elapsed) /* INFINITE is MAX_UINT */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1327 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1328 if (timeout_ms != INFINITE) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1329 timeout_ms -= elapsed; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1330 goto count_children; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1331 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1332 } |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1333 |
9907 | 1334 return nr; |
1335 } | |
1336 | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1337 /* Substitute for certain kill () operations */ |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1338 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1339 static BOOL CALLBACK |
31115
42753ce203f8
(IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents:
26526
diff
changeset
|
1340 find_child_console (HWND hwnd, LPARAM arg) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1341 { |
31115
42753ce203f8
(IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents:
26526
diff
changeset
|
1342 child_process * cp = (child_process *) arg; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1343 DWORD thread_id; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1344 DWORD process_id; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1345 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1346 thread_id = GetWindowThreadProcessId (hwnd, &process_id); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1347 if (process_id == cp->procinfo.dwProcessId) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1348 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1349 char window_class[32]; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1350 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1351 GetClassName (hwnd, window_class, sizeof (window_class)); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1352 if (strcmp (window_class, |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1353 (os_subtype == OS_WIN95) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1354 ? "tty" |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1355 : "ConsoleWindowClass") == 0) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1356 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1357 cp->hwnd = hwnd; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1358 return FALSE; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1359 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1360 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1361 /* keep looking */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1362 return TRUE; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1363 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1364 |
9907 | 1365 int |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1366 sys_kill (int pid, int sig) |
9907 | 1367 { |
1368 child_process *cp; | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1369 HANDLE proc_hand; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1370 int need_to_free = 0; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1371 int rc = 0; |
9907 | 1372 |
1373 /* Only handle signals that will result in the process dying */ | |
1374 if (sig != SIGINT && sig != SIGKILL && sig != SIGQUIT && sig != SIGHUP) | |
1375 { | |
1376 errno = EINVAL; | |
1377 return -1; | |
1378 } | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1379 |
9907 | 1380 cp = find_child_pid (pid); |
1381 if (cp == NULL) | |
1382 { | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1383 proc_hand = OpenProcess (PROCESS_TERMINATE, 0, pid); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1384 if (proc_hand == NULL) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1385 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1386 errno = EPERM; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1387 return -1; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1388 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1389 need_to_free = 1; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1390 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1391 else |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1392 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1393 proc_hand = cp->procinfo.hProcess; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1394 pid = cp->procinfo.dwProcessId; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1395 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1396 /* Try to locate console window for process. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1397 EnumWindows (find_child_console, (LPARAM) cp); |
9907 | 1398 } |
1399 | |
38022
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
1400 if (sig == SIGINT || sig == SIGQUIT) |
9907 | 1401 { |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1402 if (NILP (Vw32_start_process_share_console) && cp && cp->hwnd) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1403 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1404 BYTE control_scan_code = (BYTE) MapVirtualKey (VK_CONTROL, 0); |
38022
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
1405 /* Fake Ctrl-C for SIGINT, and Ctrl-Break for SIGQUIT. */ |
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
1406 BYTE vk_break_code = (sig == SIGINT) ? 'C' : VK_CANCEL; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1407 BYTE break_scan_code = (BYTE) MapVirtualKey (vk_break_code, 0); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1408 HWND foreground_window; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1409 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1410 if (break_scan_code == 0) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1411 { |
38022
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
1412 /* Fake Ctrl-C for SIGQUIT if we can't manage Ctrl-Break. */ |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1413 vk_break_code = 'C'; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1414 break_scan_code = (BYTE) MapVirtualKey (vk_break_code, 0); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1415 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1416 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1417 foreground_window = GetForegroundWindow (); |
24671
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1418 if (foreground_window) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1419 { |
24671
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1420 /* NT 5.0, and apparently also Windows 98, will not allow |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1421 a Window to be set to foreground directly without the |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1422 user's involvement. The workaround is to attach |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1423 ourselves to the thread that owns the foreground |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1424 window, since that is the only thread that can set the |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1425 foreground window. */ |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1426 DWORD foreground_thread, child_thread; |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1427 foreground_thread = |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1428 GetWindowThreadProcessId (foreground_window, NULL); |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1429 if (foreground_thread == GetCurrentThreadId () |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1430 || !AttachThreadInput (GetCurrentThreadId (), |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1431 foreground_thread, TRUE)) |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1432 foreground_thread = 0; |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1433 |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1434 child_thread = GetWindowThreadProcessId (cp->hwnd, NULL); |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1435 if (child_thread == GetCurrentThreadId () |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1436 || !AttachThreadInput (GetCurrentThreadId (), |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1437 child_thread, TRUE)) |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1438 child_thread = 0; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1439 |
24671
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1440 /* Set the foreground window to the child. */ |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1441 if (SetForegroundWindow (cp->hwnd)) |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1442 { |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1443 /* Generate keystrokes as if user had typed Ctrl-Break or |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1444 Ctrl-C. */ |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1445 keybd_event (VK_CONTROL, control_scan_code, 0, 0); |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1446 keybd_event (vk_break_code, break_scan_code, |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1447 (vk_break_code == 'C' ? 0 : KEYEVENTF_EXTENDEDKEY), 0); |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1448 keybd_event (vk_break_code, break_scan_code, |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1449 (vk_break_code == 'C' ? 0 : KEYEVENTF_EXTENDEDKEY) |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1450 | KEYEVENTF_KEYUP, 0); |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1451 keybd_event (VK_CONTROL, control_scan_code, |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1452 KEYEVENTF_KEYUP, 0); |
21613
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1453 |
24671
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1454 /* Sleep for a bit to give time for Emacs frame to respond |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1455 to focus change events (if Emacs was active app). */ |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1456 Sleep (100); |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1457 |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1458 SetForegroundWindow (foreground_window); |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1459 } |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1460 /* Detach from the foreground and child threads now that |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1461 the foreground switching is over. */ |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1462 if (foreground_thread) |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1463 AttachThreadInput (GetCurrentThreadId (), |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1464 foreground_thread, FALSE); |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1465 if (child_thread) |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1466 AttachThreadInput (GetCurrentThreadId (), |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1467 child_thread, FALSE); |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1468 } |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1469 } |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1470 /* Ctrl-Break is NT equivalent of SIGINT. */ |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1471 else if (!GenerateConsoleCtrlEvent (CTRL_BREAK_EVENT, pid)) |
9907 | 1472 { |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1473 DebPrint (("sys_kill.GenerateConsoleCtrlEvent return %d " |
9907 | 1474 "for pid %lu\n", GetLastError (), pid)); |
1475 errno = EINVAL; | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1476 rc = -1; |
21742
b1c3fe58dbbe
(sys_kill): Fix indenting.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21613
diff
changeset
|
1477 } |
9907 | 1478 } |
1479 else | |
1480 { | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1481 if (NILP (Vw32_start_process_share_console) && cp && cp->hwnd) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1482 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1483 #if 1 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1484 if (os_subtype == OS_WIN95) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1485 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1486 /* |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1487 Another possibility is to try terminating the VDM out-right by |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1488 calling the Shell VxD (id 0x17) V86 interface, function #4 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1489 "SHELL_Destroy_VM", ie. |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1490 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1491 mov edx,4 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1492 mov ebx,vm_handle |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1493 call shellapi |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1494 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1495 First need to determine the current VM handle, and then arrange for |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1496 the shellapi call to be made from the system vm (by using |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1497 Switch_VM_and_callback). |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1498 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1499 Could try to invoke DestroyVM through CallVxD. |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1500 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1501 */ |
21613
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1502 #if 0 |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1503 /* On Win95, posting WM_QUIT causes the 16-bit subsystem |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1504 to hang when cmdproxy is used in conjunction with |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1505 command.com for an interactive shell. Posting |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1506 WM_CLOSE pops up a dialog that, when Yes is selected, |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1507 does the same thing. TerminateProcess is also less |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1508 than ideal in that subprocesses tend to stick around |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1509 until the machine is shutdown, but at least it |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1510 doesn't freeze the 16-bit subsystem. */ |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1511 PostMessage (cp->hwnd, WM_QUIT, 0xff, 0); |
21613
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1512 #endif |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1513 if (!TerminateProcess (proc_hand, 0xff)) |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1514 { |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1515 DebPrint (("sys_kill.TerminateProcess returned %d " |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1516 "for pid %lu\n", GetLastError (), pid)); |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1517 errno = EINVAL; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1518 rc = -1; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1519 } |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1520 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1521 else |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1522 #endif |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1523 PostMessage (cp->hwnd, WM_CLOSE, 0, 0); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1524 } |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
1525 /* Kill the process. On W32 this doesn't kill child processes |
15351
6deee3a18ba8
(sys_kill): Don't try to terminate a DOS process.
Richard M. Stallman <rms@gnu.org>
parents:
15325
diff
changeset
|
1526 so it doesn't work very well for shells which is why it's not |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1527 used in every case. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1528 else if (!TerminateProcess (proc_hand, 0xff)) |
9907 | 1529 { |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1530 DebPrint (("sys_kill.TerminateProcess returned %d " |
9907 | 1531 "for pid %lu\n", GetLastError (), pid)); |
1532 errno = EINVAL; | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1533 rc = -1; |
9907 | 1534 } |
1535 } | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1536 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1537 if (need_to_free) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1538 CloseHandle (proc_hand); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1539 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1540 return rc; |
9907 | 1541 } |
1542 | |
21452
bd9b548fd162
Delete incorrect prototype of report_file_error.
Karl Heuer <kwzh@gnu.org>
parents:
19712
diff
changeset
|
1543 /* extern int report_file_error (char *, Lisp_Object); */ |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1544 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1545 /* The following two routines are used to manipulate stdin, stdout, and |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1546 stderr of our child processes. |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1547 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1548 Assuming that in, out, and err are *not* inheritable, we make them |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1549 stdin, stdout, and stderr of the child as follows: |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1550 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1551 - Save the parent's current standard handles. |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1552 - Set the std handles to inheritable duplicates of the ones being passed in. |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1553 (Note that _get_osfhandle() is an io.h procedure that retrieves the |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1554 NT file handle for a crt file descriptor.) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1555 - Spawn the child, which inherits in, out, and err as stdin, |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1556 stdout, and stderr. (see Spawnve) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1557 - Close the std handles passed to the child. |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1558 - Reset the parent's standard handles to the saved handles. |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1559 (see reset_standard_handles) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1560 We assume that the caller closes in, out, and err after calling us. */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1561 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1562 void |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1563 prepare_standard_handles (int in, int out, int err, HANDLE handles[3]) |
9907 | 1564 { |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1565 HANDLE parent; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1566 HANDLE newstdin, newstdout, newstderr; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1567 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1568 parent = GetCurrentProcess (); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1569 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1570 handles[0] = GetStdHandle (STD_INPUT_HANDLE); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1571 handles[1] = GetStdHandle (STD_OUTPUT_HANDLE); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1572 handles[2] = GetStdHandle (STD_ERROR_HANDLE); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1573 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1574 /* make inheritable copies of the new handles */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1575 if (!DuplicateHandle (parent, |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1576 (HANDLE) _get_osfhandle (in), |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1577 parent, |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1578 &newstdin, |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1579 0, |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1580 TRUE, |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1581 DUPLICATE_SAME_ACCESS)) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1582 report_file_error ("Duplicating input handle for child", Qnil); |
9907 | 1583 |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1584 if (!DuplicateHandle (parent, |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1585 (HANDLE) _get_osfhandle (out), |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1586 parent, |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1587 &newstdout, |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1588 0, |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1589 TRUE, |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1590 DUPLICATE_SAME_ACCESS)) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1591 report_file_error ("Duplicating output handle for child", Qnil); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1592 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1593 if (!DuplicateHandle (parent, |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1594 (HANDLE) _get_osfhandle (err), |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1595 parent, |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1596 &newstderr, |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1597 0, |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1598 TRUE, |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1599 DUPLICATE_SAME_ACCESS)) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1600 report_file_error ("Duplicating error handle for child", Qnil); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1601 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1602 /* and store them as our std handles */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1603 if (!SetStdHandle (STD_INPUT_HANDLE, newstdin)) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1604 report_file_error ("Changing stdin handle", Qnil); |
9907 | 1605 |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1606 if (!SetStdHandle (STD_OUTPUT_HANDLE, newstdout)) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1607 report_file_error ("Changing stdout handle", Qnil); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1608 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1609 if (!SetStdHandle (STD_ERROR_HANDLE, newstderr)) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1610 report_file_error ("Changing stderr handle", Qnil); |
9907 | 1611 } |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1612 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1613 void |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1614 reset_standard_handles (int in, int out, int err, HANDLE handles[3]) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1615 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1616 /* close the duplicated handles passed to the child */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1617 CloseHandle (GetStdHandle (STD_INPUT_HANDLE)); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1618 CloseHandle (GetStdHandle (STD_OUTPUT_HANDLE)); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1619 CloseHandle (GetStdHandle (STD_ERROR_HANDLE)); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1620 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1621 /* now restore parent's saved std handles */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1622 SetStdHandle (STD_INPUT_HANDLE, handles[0]); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1623 SetStdHandle (STD_OUTPUT_HANDLE, handles[1]); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1624 SetStdHandle (STD_ERROR_HANDLE, handles[2]); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1625 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1626 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1627 void |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1628 set_process_dir (char * dir) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1629 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1630 process_dir = dir; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1631 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1632 |
15356
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1633 #ifdef HAVE_SOCKETS |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1634 |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1635 /* To avoid problems with winsock implementations that work over dial-up |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1636 connections causing or requiring a connection to exist while Emacs is |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1637 running, Emacs no longer automatically loads winsock on startup if it |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1638 is present. Instead, it will be loaded when open-network-stream is |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1639 first called. |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1640 |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1641 To allow full control over when winsock is loaded, we provide these |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1642 two functions to dynamically load and unload winsock. This allows |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1643 dial-up users to only be connected when they actually need to use |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1644 socket services. */ |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1645 |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1646 /* From nt.c */ |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1647 extern HANDLE winsock_lib; |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1648 extern BOOL term_winsock (void); |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1649 extern BOOL init_winsock (int load_now); |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1650 |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1651 extern Lisp_Object Vsystem_name; |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1652 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
1653 DEFUN ("w32-has-winsock", Fw32_has_winsock, Sw32_has_winsock, 0, 1, 0, |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1654 doc: /* Test for presence of the Windows socket library `winsock'. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1655 Returns non-nil if winsock support is present, nil otherwise. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1656 |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1657 If the optional argument LOAD-NOW is non-nil, the winsock library is |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1658 also loaded immediately if not already loaded. If winsock is loaded, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1659 the winsock local hostname is returned (since this may be different from |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1660 the value of `system-name' and should supplant it), otherwise t is |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1661 returned to indicate winsock support is present. */) |
15356
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1662 (load_now) |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1663 Lisp_Object load_now; |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1664 { |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1665 int have_winsock; |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1666 |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1667 have_winsock = init_winsock (!NILP (load_now)); |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1668 if (have_winsock) |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1669 { |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1670 if (winsock_lib != NULL) |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1671 { |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1672 /* Return new value for system-name. The best way to do this |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1673 is to call init_system_name, saving and restoring the |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1674 original value to avoid side-effects. */ |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1675 Lisp_Object orig_hostname = Vsystem_name; |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1676 Lisp_Object hostname; |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1677 |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1678 init_system_name (); |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1679 hostname = Vsystem_name; |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1680 Vsystem_name = orig_hostname; |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1681 return hostname; |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1682 } |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1683 return Qt; |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1684 } |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1685 return Qnil; |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1686 } |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1687 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
1688 DEFUN ("w32-unload-winsock", Fw32_unload_winsock, Sw32_unload_winsock, |
15356
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1689 0, 0, 0, |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1690 doc: /* Unload the Windows socket library `winsock' if loaded. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1691 This is provided to allow dial-up socket connections to be disconnected |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1692 when no longer needed. Returns nil without unloading winsock if any |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1693 socket connections still exist. */) |
15356
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1694 () |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1695 { |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1696 return term_winsock () ? Qt : Qnil; |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1697 } |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1698 |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1699 #endif /* HAVE_SOCKETS */ |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1700 |
15201
43551ec4b69d
(Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15145
diff
changeset
|
1701 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1702 /* Some miscellaneous functions that are Windows specific, but not GUI |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1703 specific (ie. are applicable in terminal or batch mode as well). */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1704 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1705 /* lifted from fileio.c */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1706 #define CORRECT_DIR_SEPS(s) \ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1707 do { if ('/' == DIRECTORY_SEP) dostounix_filename (s); \ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1708 else unixtodos_filename (s); \ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1709 } while (0) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1710 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1711 DEFUN ("w32-short-file-name", Fw32_short_file_name, Sw32_short_file_name, 1, 1, 0, |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1712 doc: /* Return the short file name version (8.3) of the full path of FILENAME. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1713 If FILENAME does not exist, return nil. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1714 All path elements in FILENAME are converted to their short names. */) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1715 (filename) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1716 Lisp_Object filename; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1717 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1718 char shortname[MAX_PATH]; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1719 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
39812
diff
changeset
|
1720 CHECK_STRING (filename); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1721 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1722 /* first expand it. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1723 filename = Fexpand_file_name (filename, Qnil); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1724 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1725 /* luckily, this returns the short version of each element in the path. */ |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45089
diff
changeset
|
1726 if (GetShortPathName (SDATA (filename), shortname, MAX_PATH) == 0) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1727 return Qnil; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1728 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1729 CORRECT_DIR_SEPS (shortname); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1730 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1731 return build_string (shortname); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1732 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1733 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1734 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1735 DEFUN ("w32-long-file-name", Fw32_long_file_name, Sw32_long_file_name, |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1736 1, 1, 0, |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1737 doc: /* Return the long file name version of the full path of FILENAME. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1738 If FILENAME does not exist, return nil. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1739 All path elements in FILENAME are converted to their long names. */) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1740 (filename) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1741 Lisp_Object filename; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1742 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1743 char longname[ MAX_PATH ]; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1744 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
39812
diff
changeset
|
1745 CHECK_STRING (filename); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1746 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1747 /* first expand it. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1748 filename = Fexpand_file_name (filename, Qnil); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1749 |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45089
diff
changeset
|
1750 if (!w32_get_long_filename (SDATA (filename), longname, MAX_PATH)) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1751 return Qnil; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1752 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1753 CORRECT_DIR_SEPS (longname); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1754 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1755 return build_string (longname); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1756 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1757 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1758 DEFUN ("w32-set-process-priority", Fw32_set_process_priority, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1759 Sw32_set_process_priority, 2, 2, 0, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1760 doc: /* Set the priority of PROCESS to PRIORITY. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1761 If PROCESS is nil, the priority of Emacs is changed, otherwise the |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1762 priority of the process whose pid is PROCESS is changed. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1763 PRIORITY should be one of the symbols high, normal, or low; |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1764 any other symbol will be interpreted as normal. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1765 |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1766 If successful, the return value is t, otherwise nil. */) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1767 (process, priority) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1768 Lisp_Object process, priority; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1769 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1770 HANDLE proc_handle = GetCurrentProcess (); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1771 DWORD priority_class = NORMAL_PRIORITY_CLASS; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1772 Lisp_Object result = Qnil; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1773 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
39812
diff
changeset
|
1774 CHECK_SYMBOL (priority); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1775 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1776 if (!NILP (process)) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1777 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1778 DWORD pid; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1779 child_process *cp; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1780 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
39812
diff
changeset
|
1781 CHECK_NUMBER (process); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1782 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1783 /* Allow pid to be an internally generated one, or one obtained |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1784 externally. This is necessary because real pids on Win95 are |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1785 negative. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1786 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1787 pid = XINT (process); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1788 cp = find_child_pid (pid); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1789 if (cp != NULL) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1790 pid = cp->procinfo.dwProcessId; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1791 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1792 proc_handle = OpenProcess (PROCESS_SET_INFORMATION, FALSE, pid); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1793 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1794 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1795 if (EQ (priority, Qhigh)) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1796 priority_class = HIGH_PRIORITY_CLASS; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1797 else if (EQ (priority, Qlow)) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1798 priority_class = IDLE_PRIORITY_CLASS; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1799 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1800 if (proc_handle != NULL) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1801 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1802 if (SetPriorityClass (proc_handle, priority_class)) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1803 result = Qt; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1804 if (!NILP (process)) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1805 CloseHandle (proc_handle); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1806 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1807 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1808 return result; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1809 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1810 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1811 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1812 DEFUN ("w32-get-locale-info", Fw32_get_locale_info, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1813 Sw32_get_locale_info, 1, 2, 0, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1814 doc: /* Return information about the Windows locale LCID. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1815 By default, return a three letter locale code which encodes the default |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1816 language as the first two characters, and the country or regionial variant |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1817 as the third letter. For example, ENU refers to `English (United States)', |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1818 while ENC means `English (Canadian)'. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1819 |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1820 If the optional argument LONGFORM is t, the long form of the locale |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1821 name is returned, e.g. `English (United States)' instead; if LONGFORM |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1822 is a number, it is interpreted as an LCTYPE constant and the corresponding |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1823 locale information is returned. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1824 |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1825 If LCID (a 16-bit number) is not a valid locale, the result is nil. */) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1826 (lcid, longform) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1827 Lisp_Object lcid, longform; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1828 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1829 int got_abbrev; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1830 int got_full; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1831 char abbrev_name[32] = { 0 }; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1832 char full_name[256] = { 0 }; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1833 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
39812
diff
changeset
|
1834 CHECK_NUMBER (lcid); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1835 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1836 if (!IsValidLocale (XINT (lcid), LCID_SUPPORTED)) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1837 return Qnil; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1838 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1839 if (NILP (longform)) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1840 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1841 got_abbrev = GetLocaleInfo (XINT (lcid), |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1842 LOCALE_SABBREVLANGNAME | LOCALE_USE_CP_ACP, |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1843 abbrev_name, sizeof (abbrev_name)); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1844 if (got_abbrev) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1845 return build_string (abbrev_name); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1846 } |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1847 else if (EQ (longform, Qt)) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1848 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1849 got_full = GetLocaleInfo (XINT (lcid), |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1850 LOCALE_SLANGUAGE | LOCALE_USE_CP_ACP, |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1851 full_name, sizeof (full_name)); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1852 if (got_full) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1853 return build_string (full_name); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1854 } |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1855 else if (NUMBERP (longform)) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1856 { |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1857 got_full = GetLocaleInfo (XINT (lcid), |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1858 XINT (longform), |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1859 full_name, sizeof (full_name)); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1860 if (got_full) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1861 return make_unibyte_string (full_name, got_full); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1862 } |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1863 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1864 return Qnil; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1865 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1866 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1867 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1868 DEFUN ("w32-get-current-locale-id", Fw32_get_current_locale_id, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1869 Sw32_get_current_locale_id, 0, 0, 0, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1870 doc: /* Return Windows locale id for current locale setting. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1871 This is a numerical value; use `w32-get-locale-info' to convert to a |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1872 human-readable form. */) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1873 () |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1874 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1875 return make_number (GetThreadLocale ()); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1876 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1877 |
21613
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1878 DWORD int_from_hex (char * s) |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1879 { |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1880 DWORD val = 0; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1881 static char hex[] = "0123456789abcdefABCDEF"; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1882 char * p; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1883 |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1884 while (*s && (p = strchr(hex, *s)) != NULL) |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1885 { |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1886 unsigned digit = p - hex; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1887 if (digit > 15) |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1888 digit -= 6; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1889 val = val * 16 + digit; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1890 s++; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1891 } |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1892 return val; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1893 } |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1894 |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1895 /* We need to build a global list, since the EnumSystemLocale callback |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1896 function isn't given a context pointer. */ |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1897 Lisp_Object Vw32_valid_locale_ids; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1898 |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1899 BOOL CALLBACK enum_locale_fn (LPTSTR localeNum) |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1900 { |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1901 DWORD id = int_from_hex (localeNum); |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1902 Vw32_valid_locale_ids = Fcons (make_number (id), Vw32_valid_locale_ids); |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1903 return TRUE; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1904 } |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1905 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1906 DEFUN ("w32-get-valid-locale-ids", Fw32_get_valid_locale_ids, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1907 Sw32_get_valid_locale_ids, 0, 0, 0, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1908 doc: /* Return list of all valid Windows locale ids. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1909 Each id is a numerical value; use `w32-get-locale-info' to convert to a |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1910 human-readable form. */) |
21613
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1911 () |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1912 { |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1913 Vw32_valid_locale_ids = Qnil; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1914 |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1915 EnumSystemLocales (enum_locale_fn, LCID_SUPPORTED); |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1916 |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1917 Vw32_valid_locale_ids = Fnreverse (Vw32_valid_locale_ids); |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1918 return Vw32_valid_locale_ids; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1919 } |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1920 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1921 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1922 DEFUN ("w32-get-default-locale-id", Fw32_get_default_locale_id, Sw32_get_default_locale_id, 0, 1, 0, |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1923 doc: /* Return Windows locale id for default locale setting. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1924 By default, the system default locale setting is returned; if the optional |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1925 parameter USERP is non-nil, the user default locale setting is returned. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1926 This is a numerical value; use `w32-get-locale-info' to convert to a |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1927 human-readable form. */) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1928 (userp) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1929 Lisp_Object userp; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1930 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1931 if (NILP (userp)) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1932 return make_number (GetSystemDefaultLCID ()); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1933 return make_number (GetUserDefaultLCID ()); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1934 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1935 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1936 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1937 DEFUN ("w32-set-current-locale", Fw32_set_current_locale, Sw32_set_current_locale, 1, 1, 0, |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1938 doc: /* Make Windows locale LCID be the current locale setting for Emacs. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1939 If successful, the new locale id is returned, otherwise nil. */) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1940 (lcid) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1941 Lisp_Object lcid; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1942 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
39812
diff
changeset
|
1943 CHECK_NUMBER (lcid); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1944 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1945 if (!IsValidLocale (XINT (lcid), LCID_SUPPORTED)) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1946 return Qnil; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1947 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1948 if (!SetThreadLocale (XINT (lcid))) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1949 return Qnil; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1950 |
21613
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1951 /* Need to set input thread locale if present. */ |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1952 if (dwWindowsThreadId) |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1953 /* Reply is not needed. */ |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1954 PostThreadMessage (dwWindowsThreadId, WM_EMACS_SETLOCALE, XINT (lcid), 0); |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1955 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1956 return make_number (GetThreadLocale ()); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1957 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1958 |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1959 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1960 /* We need to build a global list, since the EnumCodePages callback |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1961 function isn't given a context pointer. */ |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1962 Lisp_Object Vw32_valid_codepages; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1963 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1964 BOOL CALLBACK enum_codepage_fn (LPTSTR codepageNum) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1965 { |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1966 DWORD id = atoi (codepageNum); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1967 Vw32_valid_codepages = Fcons (make_number (id), Vw32_valid_codepages); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1968 return TRUE; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1969 } |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1970 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1971 DEFUN ("w32-get-valid-codepages", Fw32_get_valid_codepages, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1972 Sw32_get_valid_codepages, 0, 0, 0, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1973 doc: /* Return list of all valid Windows codepages. */) |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1974 () |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1975 { |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1976 Vw32_valid_codepages = Qnil; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1977 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1978 EnumSystemCodePages (enum_codepage_fn, CP_SUPPORTED); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1979 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1980 Vw32_valid_codepages = Fnreverse (Vw32_valid_codepages); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1981 return Vw32_valid_codepages; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1982 } |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1983 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1984 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1985 DEFUN ("w32-get-console-codepage", Fw32_get_console_codepage, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1986 Sw32_get_console_codepage, 0, 0, 0, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1987 doc: /* Return current Windows codepage for console input. */) |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1988 () |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1989 { |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1990 return make_number (GetConsoleCP ()); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1991 } |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1992 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1993 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1994 DEFUN ("w32-set-console-codepage", Fw32_set_console_codepage, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1995 Sw32_set_console_codepage, 1, 1, 0, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1996 doc: /* Make Windows codepage CP be the current codepage setting for Emacs. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1997 The codepage setting affects keyboard input and display in tty mode. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1998 If successful, the new CP is returned, otherwise nil. */) |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1999 (cp) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2000 Lisp_Object cp; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2001 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
39812
diff
changeset
|
2002 CHECK_NUMBER (cp); |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2003 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2004 if (!IsValidCodePage (XINT (cp))) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2005 return Qnil; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2006 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2007 if (!SetConsoleCP (XINT (cp))) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2008 return Qnil; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2009 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2010 return make_number (GetConsoleCP ()); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2011 } |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2012 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2013 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2014 DEFUN ("w32-get-console-output-codepage", Fw32_get_console_output_codepage, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2015 Sw32_get_console_output_codepage, 0, 0, 0, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2016 doc: /* Return current Windows codepage for console output. */) |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2017 () |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2018 { |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2019 return make_number (GetConsoleOutputCP ()); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2020 } |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2021 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2022 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2023 DEFUN ("w32-set-console-output-codepage", Fw32_set_console_output_codepage, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2024 Sw32_set_console_output_codepage, 1, 1, 0, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2025 doc: /* Make Windows codepage CP be the current codepage setting for Emacs. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2026 The codepage setting affects keyboard input and display in tty mode. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2027 If successful, the new CP is returned, otherwise nil. */) |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2028 (cp) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2029 Lisp_Object cp; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2030 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
39812
diff
changeset
|
2031 CHECK_NUMBER (cp); |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2032 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2033 if (!IsValidCodePage (XINT (cp))) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2034 return Qnil; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2035 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2036 if (!SetConsoleOutputCP (XINT (cp))) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2037 return Qnil; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2038 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2039 return make_number (GetConsoleOutputCP ()); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2040 } |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2041 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2042 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2043 DEFUN ("w32-get-codepage-charset", Fw32_get_codepage_charset, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2044 Sw32_get_codepage_charset, 1, 1, 0, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2045 doc: /* Return charset of codepage CP. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2046 Returns nil if the codepage is not valid. */) |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2047 (cp) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2048 Lisp_Object cp; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2049 { |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2050 CHARSETINFO info; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2051 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
39812
diff
changeset
|
2052 CHECK_NUMBER (cp); |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2053 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2054 if (!IsValidCodePage (XINT (cp))) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2055 return Qnil; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2056 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2057 if (TranslateCharsetInfo ((DWORD *) XINT (cp), &info, TCI_SRCCODEPAGE)) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2058 return make_number (info.ciCharset); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2059 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2060 return Qnil; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2061 } |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2062 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2063 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2064 DEFUN ("w32-get-valid-keyboard-layouts", Fw32_get_valid_keyboard_layouts, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2065 Sw32_get_valid_keyboard_layouts, 0, 0, 0, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2066 doc: /* Return list of Windows keyboard languages and layouts. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2067 The return value is a list of pairs of language id and layout id. */) |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2068 () |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2069 { |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2070 int num_layouts = GetKeyboardLayoutList (0, NULL); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2071 HKL * layouts = (HKL *) alloca (num_layouts * sizeof (HKL)); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2072 Lisp_Object obj = Qnil; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2073 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2074 if (GetKeyboardLayoutList (num_layouts, layouts) == num_layouts) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2075 { |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2076 while (--num_layouts >= 0) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2077 { |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2078 DWORD kl = (DWORD) layouts[num_layouts]; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2079 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2080 obj = Fcons (Fcons (make_number (kl & 0xffff), |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2081 make_number ((kl >> 16) & 0xffff)), |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2082 obj); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2083 } |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2084 } |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2085 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2086 return obj; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2087 } |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2088 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2089 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2090 DEFUN ("w32-get-keyboard-layout", Fw32_get_keyboard_layout, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2091 Sw32_get_keyboard_layout, 0, 0, 0, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2092 doc: /* Return current Windows keyboard language and layout. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2093 The return value is the cons of the language id and the layout id. */) |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2094 () |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2095 { |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2096 DWORD kl = (DWORD) GetKeyboardLayout (dwWindowsThreadId); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2097 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2098 return Fcons (make_number (kl & 0xffff), |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2099 make_number ((kl >> 16) & 0xffff)); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2100 } |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2101 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2102 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2103 DEFUN ("w32-set-keyboard-layout", Fw32_set_keyboard_layout, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2104 Sw32_set_keyboard_layout, 1, 1, 0, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2105 doc: /* Make LAYOUT be the current keyboard layout for Emacs. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2106 The keyboard layout setting affects interpretation of keyboard input. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2107 If successful, the new layout id is returned, otherwise nil. */) |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2108 (layout) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2109 Lisp_Object layout; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2110 { |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2111 DWORD kl; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2112 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
39812
diff
changeset
|
2113 CHECK_CONS (layout); |
40752
8b5deb3bca03
(Fw32_set_keyboard_layout): Use CHECK_NUMBER_CAR and
Andrew Innes <andrewi@gnu.org>
parents:
40656
diff
changeset
|
2114 CHECK_NUMBER_CAR (layout); |
8b5deb3bca03
(Fw32_set_keyboard_layout): Use CHECK_NUMBER_CAR and
Andrew Innes <andrewi@gnu.org>
parents:
40656
diff
changeset
|
2115 CHECK_NUMBER_CDR (layout); |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2116 |
25646
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
24915
diff
changeset
|
2117 kl = (XINT (XCAR (layout)) & 0xffff) |
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
24915
diff
changeset
|
2118 | (XINT (XCDR (layout)) << 16); |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2119 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2120 /* Synchronize layout with input thread. */ |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2121 if (dwWindowsThreadId) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2122 { |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2123 if (PostThreadMessage (dwWindowsThreadId, WM_EMACS_SETKEYBOARDLAYOUT, |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2124 (WPARAM) kl, 0)) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2125 { |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2126 MSG msg; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2127 GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2128 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2129 if (msg.wParam == 0) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2130 return Qnil; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2131 } |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2132 } |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2133 else if (!ActivateKeyboardLayout ((HKL) kl, 0)) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2134 return Qnil; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2135 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2136 return Fw32_get_keyboard_layout (); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2137 } |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2138 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2139 |
15201
43551ec4b69d
(Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15145
diff
changeset
|
2140 syms_of_ntproc () |
43551ec4b69d
(Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15145
diff
changeset
|
2141 { |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2142 Qhigh = intern ("high"); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2143 Qlow = intern ("low"); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2144 |
15356
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
2145 #ifdef HAVE_SOCKETS |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
2146 defsubr (&Sw32_has_winsock); |
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
2147 defsubr (&Sw32_unload_winsock); |
15356
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
2148 #endif |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2149 defsubr (&Sw32_short_file_name); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2150 defsubr (&Sw32_long_file_name); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2151 defsubr (&Sw32_set_process_priority); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2152 defsubr (&Sw32_get_locale_info); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2153 defsubr (&Sw32_get_current_locale_id); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2154 defsubr (&Sw32_get_default_locale_id); |
21613
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2155 defsubr (&Sw32_get_valid_locale_ids); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2156 defsubr (&Sw32_set_current_locale); |
15356
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
2157 |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2158 defsubr (&Sw32_get_console_codepage); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2159 defsubr (&Sw32_set_console_codepage); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2160 defsubr (&Sw32_get_console_output_codepage); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2161 defsubr (&Sw32_set_console_output_codepage); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2162 defsubr (&Sw32_get_valid_codepages); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2163 defsubr (&Sw32_get_codepage_charset); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2164 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2165 defsubr (&Sw32_get_valid_keyboard_layouts); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2166 defsubr (&Sw32_get_keyboard_layout); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2167 defsubr (&Sw32_set_keyboard_layout); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2168 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
2169 DEFVAR_LISP ("w32-quote-process-args", &Vw32_quote_process_args, |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2170 doc: /* Non-nil enables quoting of process arguments to ensure correct parsing. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2171 Because Windows does not directly pass argv arrays to child processes, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2172 programs have to reconstruct the argv array by parsing the command |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2173 line string. For an argument to contain a space, it must be enclosed |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2174 in double quotes or it will be parsed as multiple arguments. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2175 |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2176 If the value is a character, that character will be used to escape any |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2177 quote characters that appear, otherwise a suitable escape character |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2178 will be chosen based on the type of the program. */); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2179 Vw32_quote_process_args = Qt; |
15247
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
2180 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
2181 DEFVAR_LISP ("w32-start-process-show-window", |
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
2182 &Vw32_start_process_show_window, |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2183 doc: /* When nil, new child processes hide their windows. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2184 When non-nil, they show their window in the method of their choice. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2185 This variable doesn't affect GUI applications, which will never be hidden. */); |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
2186 Vw32_start_process_show_window = Qnil; |
16000
b5ecd5022991
(Vwin32_start_process_show_window): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15419
diff
changeset
|
2187 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2188 DEFVAR_LISP ("w32-start-process-share-console", |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2189 &Vw32_start_process_share_console, |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2190 doc: /* When nil, new child processes are given a new console. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2191 When non-nil, they share the Emacs console; this has the limitation of |
43548
c185eb97b9ee
(syms_of_ntproc): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
42469
diff
changeset
|
2192 allowing only one DOS subprocess to run at a time (whether started directly |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2193 or indirectly by Emacs), and preventing Emacs from cleanly terminating the |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2194 subprocess group, but may allow Emacs to interrupt a subprocess that doesn't |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2195 otherwise respond to interrupts from Emacs. */); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2196 Vw32_start_process_share_console = Qnil; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2197 |
23949
9f8417cca07b
(Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents:
23678
diff
changeset
|
2198 DEFVAR_LISP ("w32-start-process-inherit-error-mode", |
9f8417cca07b
(Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents:
23678
diff
changeset
|
2199 &Vw32_start_process_inherit_error_mode, |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2200 doc: /* When nil, new child processes revert to the default error mode. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2201 When non-nil, they inherit their error mode setting from Emacs, which stops |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2202 them blocking when trying to access unmounted drives etc. */); |
23949
9f8417cca07b
(Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents:
23678
diff
changeset
|
2203 Vw32_start_process_inherit_error_mode = Qt; |
9f8417cca07b
(Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents:
23678
diff
changeset
|
2204 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
2205 DEFVAR_INT ("w32-pipe-read-delay", &Vw32_pipe_read_delay, |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2206 doc: /* Forced delay before reading subprocess output. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2207 This is done to improve the buffering of subprocess output, by |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2208 avoiding the inefficiency of frequently reading small amounts of data. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2209 |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2210 If positive, the value is the number of milliseconds to sleep before |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2211 reading the subprocess output. If negative, the magnitude is the number |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2212 of time slices to wait (effectively boosting the priority of the child |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2213 process temporarily). A value of zero disables waiting entirely. */); |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
2214 Vw32_pipe_read_delay = 50; |
15325
5c8e4ef3137c
(Vwin32_downcase_file_names): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15247
diff
changeset
|
2215 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
2216 DEFVAR_LISP ("w32-downcase-file-names", &Vw32_downcase_file_names, |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2217 doc: /* Non-nil means convert all-upper case file names to lower case. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2218 This applies when performing completions and file name expansion. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2219 Note that the value of this setting also affects remote file names, |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2220 so you probably don't want to set to non-nil if you use case-sensitive |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2221 filesystems via ange-ftp. */); |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
2222 Vw32_downcase_file_names = Qnil; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2223 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2224 #if 0 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2225 DEFVAR_LISP ("w32-generate-fake-inodes", &Vw32_generate_fake_inodes, |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2226 doc: /* Non-nil means attempt to fake realistic inode values. |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2227 This works by hashing the truename of files, and should detect |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2228 aliasing between long and short (8.3 DOS) names, but can have |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2229 false positives because of hash collisions. Note that determing |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2230 the truename of a file can be slow. */); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2231 Vw32_generate_fake_inodes = Qnil; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2232 #endif |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2233 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2234 DEFVAR_LISP ("w32-get-true-file-attributes", &Vw32_get_true_file_attributes, |
46748
15a19dbe41bc
(syms_of_ntproc): Fix docstring of `w32-get-true-file-attributes'.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
2235 doc: /* Non-nil means determine accurate link count in `file-attributes'. |
15a19dbe41bc
(syms_of_ntproc): Fix docstring of `w32-get-true-file-attributes'.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
2236 Note that this option is only useful for files on NTFS volumes, where hard links |
46750
514398573221
Add missing semicolon.
Juanma Barranquero <lekktu@gmail.com>
parents:
46748
diff
changeset
|
2237 are supported. Moreover, it slows down `file-attributes' noticeably. */); |
44928
c887ee4e08f3
(syms_of_w32proc): Get true file attributes by default.
Jason Rumney <jasonr@gnu.org>
parents:
43548
diff
changeset
|
2238 Vw32_get_true_file_attributes = Qt; |
15201
43551ec4b69d
(Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15145
diff
changeset
|
2239 } |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
2240 /* end of ntproc.c */ |