Mercurial > emacs
annotate src/w32proc.c @ 111147:b8d9a3e4de08
Regenerated.
author | Lars Magne Ingebrigtsen <larsi@gnus.org> |
---|---|
date | Sun, 24 Oct 2010 22:47:22 +0200 |
parents | b8fde5ef9e14 |
children | 3207606734d5 |
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. |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94839
diff
changeset
|
2 Copyright (C) 1992, 1995, 1999, 2000, 2001, 2002, 2003, 2004, 2005, |
106815 | 3 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
9907 | 4 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
5 This file is part of GNU Emacs. |
9907 | 6 |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94839
diff
changeset
|
7 GNU Emacs is free software: you can redistribute it and/or modify |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
8 it under the terms of the GNU General Public License as published by |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94839
diff
changeset
|
9 the Free Software Foundation, either version 3 of the License, or |
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94839
diff
changeset
|
10 (at your option) any later version. |
9907 | 11 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
12 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
|
13 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
|
14 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
|
15 GNU General Public License for more details. |
9907 | 16 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94839
diff
changeset
|
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
9907 | 19 |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94839
diff
changeset
|
20 /* |
9907 | 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> |
105669
68dd71358159
* alloc.c: Do not define struct catchtag.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
103813
diff
changeset
|
32 #include <setjmp.h> |
9907 | 33 |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
34 /* must include CRT headers *before* config.h */ |
42469 | 35 |
36 #ifdef HAVE_CONFIG_H | |
37 #include <config.h> | |
38 #endif | |
39 | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
40 #undef signal |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
41 #undef wait |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
42 #undef spawnve |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
43 #undef select |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
44 #undef kill |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
45 |
9907 | 46 #include <windows.h> |
31115
42753ce203f8
(IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents:
26526
diff
changeset
|
47 #ifdef __GNUC__ |
42753ce203f8
(IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents:
26526
diff
changeset
|
48 /* This definition is missing from mingw32 headers. */ |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
49 extern BOOL WINAPI IsValidLocale (LCID, DWORD); |
31115
42753ce203f8
(IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents:
26526
diff
changeset
|
50 #endif |
9907 | 51 |
73091
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
52 #ifdef HAVE_LANGINFO_CODESET |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
53 #include <nl_types.h> |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
54 #include <langinfo.h> |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
55 #endif |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
56 |
9907 | 57 #include "lisp.h" |
90929 | 58 #include "character.h" |
16593
4ed80eda6fac
Use new names for w32 files
Geoff Voelker <voelker@cs.washington.edu>
parents:
16588
diff
changeset
|
59 #include "w32.h" |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
60 #include "w32heap.h" |
9907 | 61 #include "systime.h" |
13931
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
62 #include "syswait.h" |
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
63 #include "process.h" |
37703
d0b43907dca5
Include syssignal.h, to avoid compiler warnings.
Eli Zaretskii <eliz@gnu.org>
parents:
37290
diff
changeset
|
64 #include "syssignal.h" |
21613
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
65 #include "w32term.h" |
95277 | 66 #include "dispextern.h" /* for xstrcasecmp */ |
100045
3ec2cc2d35c1
* w32proc.c: Include "coding.h".
Juanma Barranquero <lekktu@gmail.com>
parents:
96893
diff
changeset
|
67 #include "coding.h" |
13931
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
68 |
63087 | 69 #define RVA_TO_PTR(var,section,filedata) \ |
70 ((void *)((section)->PointerToRawData \ | |
71 + ((DWORD)(var) - (section)->VirtualAddress) \ | |
72 + (filedata).file_base)) | |
73 | |
15201
43551ec4b69d
(Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15145
diff
changeset
|
74 /* 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
|
75 correct parsing by child process. Because not all uses of spawnve |
96376
c3309dba6542
American English spelling fix.
Glenn Morris <rgm@gnu.org>
parents:
96361
diff
changeset
|
76 are careful about constructing argv arrays, we make this behavior |
15201
43551ec4b69d
(Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15145
diff
changeset
|
77 conditional (off by default). */ |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
78 Lisp_Object Vw32_quote_process_args; |
15201
43551ec4b69d
(Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15145
diff
changeset
|
79 |
16000
b5ecd5022991
(Vwin32_start_process_show_window): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15419
diff
changeset
|
80 /* 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
|
81 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
|
82 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
|
83 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
84 /* Control whether create_child causes the process to inherit Emacs' |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
85 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
|
86 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
|
87 consoles also allows Emacs to cleanly terminate process groups. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
88 Lisp_Object Vw32_start_process_share_console; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
89 |
23949
9f8417cca07b
(Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents:
23678
diff
changeset
|
90 /* 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
|
91 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
|
92 subprocesses blocking when accessing unmounted drives. */ |
9f8417cca07b
(Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents:
23678
diff
changeset
|
93 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
|
94 |
15247
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
95 /* 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
|
96 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
|
97 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
|
98 but is useful for W32 processes on both Windows 95 and NT as well. */ |
55642
d69e0fb91340
* w32proc.c (w32_pipe_read_delay): Rename from Vw32_pipe_read_delay
Jason Rumney <jasonr@gnu.org>
parents:
52401
diff
changeset
|
99 int w32_pipe_read_delay; |
15247
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
100 |
15325
5c8e4ef3137c
(Vwin32_downcase_file_names): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15247
diff
changeset
|
101 /* 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
|
102 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
|
103 Lisp_Object Vw32_downcase_file_names; |
15325
5c8e4ef3137c
(Vwin32_downcase_file_names): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15247
diff
changeset
|
104 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
105 /* Control whether stat() attempts to generate fake but hopefully |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
106 "accurate" inode values, by hashing the absolute truenames of files. |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
107 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
|
108 allows the possibility of hash collisions. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
109 Lisp_Object Vw32_generate_fake_inodes; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
110 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
111 /* 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
|
112 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
|
113 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
|
114 Lisp_Object Vw32_get_true_file_attributes; |
80485
f1f27e9c15d7
(syms_of_ntproc): Change Vw32_get_true_file attributes
Jason Rumney <jasonr@gnu.org>
parents:
79759
diff
changeset
|
115 extern Lisp_Object Qlocal; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
116 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
117 Lisp_Object Qhigh, Qlow; |
15247
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
118 |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
119 #ifdef EMACSDEBUG |
109152
e27859da5624
src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
108888
diff
changeset
|
120 void |
e27859da5624
src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
108888
diff
changeset
|
121 _DebPrint (const char *fmt, ...) |
9907 | 122 { |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
123 char buf[1024]; |
9907 | 124 va_list args; |
125 | |
126 va_start (args, fmt); | |
127 vsprintf (buf, fmt, args); | |
128 va_end (args); | |
129 OutputDebugString (buf); | |
130 } | |
131 #endif | |
132 | |
109160
f8660b83cdbf
Fix whitespace to follow coding guidelines.
Juanma Barranquero <lekktu@gmail.com>
parents:
109152
diff
changeset
|
133 typedef void (_CALLBACK_ *signal_handler) (int); |
9907 | 134 |
135 /* Signal handlers...SIG_DFL == 0 so this is initialized correctly. */ | |
136 static signal_handler sig_handlers[NSIG]; | |
137 | |
138 /* Fake signal implementation to record the SIGCHLD handler. */ | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
139 signal_handler |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
140 sys_signal (int sig, signal_handler handler) |
9907 | 141 { |
142 signal_handler old; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
143 |
9907 | 144 if (sig != SIGCHLD) |
145 { | |
146 errno = EINVAL; | |
147 return SIG_ERR; | |
148 } | |
149 old = sig_handlers[sig]; | |
150 sig_handlers[sig] = handler; | |
151 return old; | |
152 } | |
153 | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
154 /* 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
|
155 #define _P_NOWAIT 1 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
156 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
157 /* Child process management list. */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
158 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
|
159 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
|
160 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
|
161 |
110975
e0ac9a58795e
src/w32*.c: Make functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110431
diff
changeset
|
162 static DWORD WINAPI reader_thread (void *arg); |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
163 |
9907 | 164 /* 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
|
165 child_process * |
9907 | 166 new_child (void) |
167 { | |
168 child_process *cp; | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
169 DWORD id; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
170 |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
171 for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--) |
9907 | 172 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
|
173 goto Initialise; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
174 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
|
175 return NULL; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
176 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
|
177 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
178 Initialise: |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
179 memset (cp, 0, sizeof (*cp)); |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
180 cp->fd = -1; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
181 cp->pid = -1; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
182 cp->procinfo.hProcess = NULL; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
183 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
|
184 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
185 /* 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
|
186 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
|
187 if (cp->char_avail) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
188 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
189 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
|
190 if (cp->char_consumed) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
191 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
192 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
|
193 if (cp->thrd) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
194 return cp; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
195 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
196 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
197 delete_child (cp); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
198 return NULL; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
199 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
200 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
201 void |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
202 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
|
203 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
204 int i; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
205 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
206 /* 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
|
207 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
|
208 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
|
209 abort (); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
210 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
211 if (!CHILD_ACTIVE (cp)) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
212 return; |
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 /* reap thread if necessary */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
215 if (cp->thrd) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
216 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
217 DWORD rc; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
218 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
219 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
|
220 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
221 /* 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
|
222 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
|
223 SetEvent (cp->char_consumed); |
78726
bede1aa77f62
(delete_child): Don't terminate threads of zombies.
Jason Rumney <jasonr@gnu.org>
parents:
78260
diff
changeset
|
224 #if 0 |
bede1aa77f62
(delete_child): Don't terminate threads of zombies.
Jason Rumney <jasonr@gnu.org>
parents:
78260
diff
changeset
|
225 /* We used to forceably terminate the thread here, but it |
bede1aa77f62
(delete_child): Don't terminate threads of zombies.
Jason Rumney <jasonr@gnu.org>
parents:
78260
diff
changeset
|
226 is normally unnecessary, and in abnormal cases, the worst that |
bede1aa77f62
(delete_child): Don't terminate threads of zombies.
Jason Rumney <jasonr@gnu.org>
parents:
78260
diff
changeset
|
227 will happen is we have an extra idle thread hanging around |
bede1aa77f62
(delete_child): Don't terminate threads of zombies.
Jason Rumney <jasonr@gnu.org>
parents:
78260
diff
changeset
|
228 waiting for the zombie process. */ |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
229 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
|
230 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
231 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
|
232 "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
|
233 TerminateThread (cp->thrd, 0); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
234 } |
78726
bede1aa77f62
(delete_child): Don't terminate threads of zombies.
Jason Rumney <jasonr@gnu.org>
parents:
78260
diff
changeset
|
235 #endif |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
236 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
237 CloseHandle (cp->thrd); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
238 cp->thrd = NULL; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
239 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
240 if (cp->char_avail) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
241 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
242 CloseHandle (cp->char_avail); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
243 cp->char_avail = NULL; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
244 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
245 if (cp->char_consumed) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
246 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
247 CloseHandle (cp->char_consumed); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
248 cp->char_consumed = NULL; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
249 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
250 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
251 /* 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
|
252 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
|
253 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
254 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
|
255 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
|
256 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
257 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
|
258 break; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
259 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
260 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
261 if (i < 0) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
262 child_proc_count = 0; |
9907 | 263 } |
264 | |
265 /* Find a child by pid. */ | |
266 static child_process * | |
267 find_child_pid (DWORD pid) | |
268 { | |
269 child_process *cp; | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
270 |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
271 for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--) |
9907 | 272 if (CHILD_ACTIVE (cp) && pid == cp->pid) |
273 return cp; | |
274 return NULL; | |
275 } | |
276 | |
277 | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
278 /* 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
|
279 is normally blocked until woken by select() to check for input by |
96361
a99299e4d2de
American English spelling fix.
Glenn Morris <rgm@gnu.org>
parents:
95277
diff
changeset
|
280 reading one char. When the read completes, char_avail is signaled |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
281 to wake up the select emulator and the thread blocks itself again. */ |
110975
e0ac9a58795e
src/w32*.c: Make functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110431
diff
changeset
|
282 static DWORD WINAPI |
9907 | 283 reader_thread (void *arg) |
284 { | |
285 child_process *cp; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
286 |
9907 | 287 /* Our identity */ |
288 cp = (child_process *)arg; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
289 |
9907 | 290 /* 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
|
291 if (cp == NULL |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
292 || 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
|
293 return 1; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
294 |
9907 | 295 for (;;) |
296 { | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
297 int rc; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
298 |
71901
7c2a2cf361cb
(reader_thread): Use _sys_wait_accept to wait on a
Kim F. Storm <storm@cua.dk>
parents:
68651
diff
changeset
|
299 if (fd_info[cp->fd].flags & FILE_LISTEN) |
7c2a2cf361cb
(reader_thread): Use _sys_wait_accept to wait on a
Kim F. Storm <storm@cua.dk>
parents:
68651
diff
changeset
|
300 rc = _sys_wait_accept (cp->fd); |
7c2a2cf361cb
(reader_thread): Use _sys_wait_accept to wait on a
Kim F. Storm <storm@cua.dk>
parents:
68651
diff
changeset
|
301 else |
7c2a2cf361cb
(reader_thread): Use _sys_wait_accept to wait on a
Kim F. Storm <storm@cua.dk>
parents:
68651
diff
changeset
|
302 rc = _sys_read_ahead (cp->fd); |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
303 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
304 /* 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
|
305 read-ahead has completed, whether successfully or not. */ |
9907 | 306 if (!SetEvent (cp->char_avail)) |
307 { | |
308 DebPrint (("reader_thread.SetEvent failed with %lu for fd %ld\n", | |
309 GetLastError (), cp->fd)); | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
310 return 1; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
311 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
312 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
313 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
|
314 return 1; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
315 |
9907 | 316 /* 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
|
317 if (rc == STATUS_READ_FAILED) |
9907 | 318 break; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
319 |
9907 | 320 /* Wait until our input is acknowledged before reading again */ |
321 if (WaitForSingleObject (cp->char_consumed, INFINITE) != WAIT_OBJECT_0) | |
322 { | |
323 DebPrint (("reader_thread.WaitForSingleObject failed with " | |
324 "%lu for fd %ld\n", GetLastError (), cp->fd)); | |
325 break; | |
326 } | |
327 } | |
328 return 0; | |
329 } | |
330 | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
331 /* 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
|
332 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
|
333 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
|
334 static char * process_dir; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
335 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
336 static BOOL |
38022
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
337 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
|
338 int * pPid, child_process *cp) |
9907 | 339 { |
340 STARTUPINFO start; | |
341 SECURITY_ATTRIBUTES sec_attrs; | |
31115
42753ce203f8
(IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents:
26526
diff
changeset
|
342 #if 0 |
9907 | 343 SECURITY_DESCRIPTOR sec_desc; |
31115
42753ce203f8
(IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents:
26526
diff
changeset
|
344 #endif |
23949
9f8417cca07b
(Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents:
23678
diff
changeset
|
345 DWORD flags; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
346 char dir[ MAXPATHLEN ]; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
347 |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
348 if (cp == NULL) abort (); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
349 |
9907 | 350 memset (&start, 0, sizeof (start)); |
351 start.cb = sizeof (start); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
352 |
13425
b6eacb7da9f6
[HAVE_NTGUI] (create_child): Pass handles to children.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12325
diff
changeset
|
353 #ifdef HAVE_NTGUI |
38022
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
354 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
|
355 start.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; |
b5ecd5022991
(Vwin32_start_process_show_window): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15419
diff
changeset
|
356 else |
b5ecd5022991
(Vwin32_start_process_show_window): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15419
diff
changeset
|
357 start.dwFlags = STARTF_USESTDHANDLES; |
13425
b6eacb7da9f6
[HAVE_NTGUI] (create_child): Pass handles to children.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12325
diff
changeset
|
358 start.wShowWindow = SW_HIDE; |
b6eacb7da9f6
[HAVE_NTGUI] (create_child): Pass handles to children.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12325
diff
changeset
|
359 |
b6eacb7da9f6
[HAVE_NTGUI] (create_child): Pass handles to children.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12325
diff
changeset
|
360 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
|
361 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
|
362 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
|
363 #endif /* HAVE_NTGUI */ |
b6eacb7da9f6
[HAVE_NTGUI] (create_child): Pass handles to children.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12325
diff
changeset
|
364 |
31115
42753ce203f8
(IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents:
26526
diff
changeset
|
365 #if 0 |
9907 | 366 /* Explicitly specify no security */ |
367 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
|
368 goto EH_Fail; |
9907 | 369 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
|
370 goto EH_Fail; |
31115
42753ce203f8
(IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents:
26526
diff
changeset
|
371 #endif |
9907 | 372 sec_attrs.nLength = sizeof (sec_attrs); |
31115
42753ce203f8
(IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents:
26526
diff
changeset
|
373 sec_attrs.lpSecurityDescriptor = NULL /* &sec_desc */; |
9907 | 374 sec_attrs.bInheritHandle = FALSE; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
375 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
376 strcpy (dir, process_dir); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
377 unixtodos_filename (dir); |
23949
9f8417cca07b
(Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents:
23678
diff
changeset
|
378 |
9f8417cca07b
(Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents:
23678
diff
changeset
|
379 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
|
380 ? CREATE_NEW_PROCESS_GROUP |
9f8417cca07b
(Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents:
23678
diff
changeset
|
381 : CREATE_NEW_CONSOLE); |
9f8417cca07b
(Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents:
23678
diff
changeset
|
382 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
|
383 flags |= CREATE_DEFAULT_ERROR_MODE; |
9907 | 384 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
|
385 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
|
386 goto EH_Fail; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
387 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
388 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
|
389 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
390 /* 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
|
391 if (cp->pid < 0) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
392 cp->pid = -cp->pid; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
393 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
394 /* pid must fit in a Lisp_Int */ |
55674
97c2d7314ac2
(create_child): Use INTMASK.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55648
diff
changeset
|
395 cp->pid = cp->pid & INTMASK; |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
396 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
397 *pPid = cp->pid; |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
398 |
9907 | 399 return TRUE; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
400 |
9907 | 401 EH_Fail: |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
402 DebPrint (("create_child.CreateProcess failed: %ld\n", GetLastError ());); |
9907 | 403 return FALSE; |
404 } | |
405 | |
406 /* create_child doesn't know what emacs' file handle will be for waiting | |
407 on output from the child, so we need to make this additional call | |
408 to register the handle with the process | |
409 This way the select emulator knows how to match file handles with | |
410 entries in child_procs. */ | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
411 void |
9907 | 412 register_child (int pid, int fd) |
413 { | |
414 child_process *cp; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
415 |
9907 | 416 cp = find_child_pid (pid); |
417 if (cp == NULL) | |
418 { | |
419 DebPrint (("register_child unable to find pid %lu\n", pid)); | |
420 return; | |
421 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
422 |
9907 | 423 #ifdef FULL_DEBUG |
424 DebPrint (("register_child registered fd %d with pid %lu\n", fd, pid)); | |
425 #endif | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
426 |
9907 | 427 cp->fd = fd; |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
428 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
429 /* 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
|
430 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
|
431 cp->status = STATUS_READ_ACKNOWLEDGED; |
9907 | 432 |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
433 /* 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
|
434 if (fd_info[fd].cp != NULL) |
9907 | 435 { |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
436 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
|
437 abort (); |
9907 | 438 } |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
439 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
440 fd_info[fd].cp = cp; |
9907 | 441 } |
442 | |
443 /* When a process dies its pipe will break so the reader thread will | |
444 signal failure to the select emulator. | |
445 The select emulator then calls this routine to clean up. | |
446 Since the thread signaled failure we can assume it is exiting. */ | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
447 static void |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
448 reap_subprocess (child_process *cp) |
9907 | 449 { |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
450 if (cp->procinfo.hProcess) |
9907 | 451 { |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
452 /* Reap the process */ |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
453 #ifdef FULL_DEBUG |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
454 /* Process should have already died before we are called. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
455 if (WaitForSingleObject (cp->procinfo.hProcess, 0) != WAIT_OBJECT_0) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
456 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
|
457 #endif |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
458 CloseHandle (cp->procinfo.hProcess); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
459 cp->procinfo.hProcess = NULL; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
460 CloseHandle (cp->procinfo.hThread); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
461 cp->procinfo.hThread = NULL; |
9907 | 462 } |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
463 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
464 /* 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
|
465 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
|
466 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
|
467 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
|
468 if (cp->fd == -1) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
469 delete_child (cp); |
9907 | 470 } |
471 | |
472 /* Wait for any of our existing child processes to die | |
473 When it does, close its handle | |
474 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
|
475 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
476 int |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
477 sys_wait (int *status) |
9907 | 478 { |
479 DWORD active, retval; | |
480 int nh; | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
481 int pid; |
9907 | 482 child_process *cp, *cps[MAX_CHILDREN]; |
483 HANDLE wait_hnd[MAX_CHILDREN]; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
484 |
9907 | 485 nh = 0; |
486 if (dead_child != NULL) | |
487 { | |
488 /* 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
|
489 wait_hnd[nh] = dead_child->procinfo.hProcess; |
9907 | 490 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
|
491 if (!wait_hnd[nh]) abort (); |
9907 | 492 nh++; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
493 active = 0; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
494 goto get_result; |
9907 | 495 } |
496 else | |
497 { | |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
498 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
|
499 /* some child_procs might be sockets; ignore them */ |
73664
a525ba4c658b
* w32proc.c: (sys_wait) Only wait for processes with fd<0.
Chong Yidong <cyd@stupidchicken.com>
parents:
73091
diff
changeset
|
500 if (CHILD_ACTIVE (cp) && cp->procinfo.hProcess |
a525ba4c658b
* w32proc.c: (sys_wait) Only wait for processes with fd<0.
Chong Yidong <cyd@stupidchicken.com>
parents:
73091
diff
changeset
|
501 && (cp->fd < 0 || (fd_info[cp->fd].flags & FILE_AT_EOF) != 0)) |
9907 | 502 { |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
503 wait_hnd[nh] = cp->procinfo.hProcess; |
9907 | 504 cps[nh] = cp; |
505 nh++; | |
506 } | |
507 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
508 |
9907 | 509 if (nh == 0) |
510 { | |
511 /* Nothing to wait on, so fail */ | |
512 errno = ECHILD; | |
513 return -1; | |
514 } | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
515 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
516 do |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
517 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
518 /* Check for quit about once a second. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
519 QUIT; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
520 active = WaitForMultipleObjects (nh, wait_hnd, FALSE, 1000); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
521 } while (active == WAIT_TIMEOUT); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
522 |
9907 | 523 if (active == WAIT_FAILED) |
524 { | |
525 errno = EBADF; | |
526 return -1; | |
527 } | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
528 else if (active >= WAIT_OBJECT_0 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
529 && active < WAIT_OBJECT_0+MAXIMUM_WAIT_OBJECTS) |
9907 | 530 { |
531 active -= WAIT_OBJECT_0; | |
532 } | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
533 else if (active >= WAIT_ABANDONED_0 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
534 && active < WAIT_ABANDONED_0+MAXIMUM_WAIT_OBJECTS) |
9907 | 535 { |
536 active -= WAIT_ABANDONED_0; | |
537 } | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
538 else |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
539 abort (); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
540 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
541 get_result: |
9907 | 542 if (!GetExitCodeProcess (wait_hnd[active], &retval)) |
543 { | |
544 DebPrint (("Wait.GetExitCodeProcess failed with %lu\n", | |
545 GetLastError ())); | |
546 retval = 1; | |
547 } | |
548 if (retval == STILL_ACTIVE) | |
549 { | |
550 /* Should never happen */ | |
551 DebPrint (("Wait.WaitForMultipleObjects returned an active process\n")); | |
552 errno = EINVAL; | |
553 return -1; | |
554 } | |
12325
aa6fc4e97a28
(win32_wait): Massage retval into what is expected in Unix.
Richard M. Stallman <rms@gnu.org>
parents:
12239
diff
changeset
|
555 |
aa6fc4e97a28
(win32_wait): Massage retval into what is expected in Unix.
Richard M. Stallman <rms@gnu.org>
parents:
12239
diff
changeset
|
556 /* Massage the exit code from the process to match the format expected |
14036 | 557 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
|
558 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
|
559 |
aa6fc4e97a28
(win32_wait): Massage retval into what is expected in Unix.
Richard M. Stallman <rms@gnu.org>
parents:
12239
diff
changeset
|
560 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
|
561 retval = SIGINT; |
aa6fc4e97a28
(win32_wait): Massage retval into what is expected in Unix.
Richard M. Stallman <rms@gnu.org>
parents:
12239
diff
changeset
|
562 else |
aa6fc4e97a28
(win32_wait): Massage retval into what is expected in Unix.
Richard M. Stallman <rms@gnu.org>
parents:
12239
diff
changeset
|
563 retval <<= 8; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
564 |
9907 | 565 cp = cps[active]; |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
566 pid = cp->pid; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
567 #ifdef FULL_DEBUG |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
568 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
|
569 #endif |
11388
96fa39ad9403
(win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
570 |
9907 | 571 if (status) |
572 { | |
11388
96fa39ad9403
(win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
573 *status = retval; |
96fa39ad9403
(win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
574 } |
96fa39ad9403
(win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
575 else if (synch_process_alive) |
96fa39ad9403
(win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
576 { |
96fa39ad9403
(win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
577 synch_process_alive = 0; |
96fa39ad9403
(win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
578 |
13931
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
579 /* 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
|
580 if (WIFEXITED (retval)) |
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
581 synch_process_retcode = WRETCODE (retval); |
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
582 else if (WIFSIGNALED (retval)) |
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
583 { |
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
584 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
|
585 char *signame; |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25646
diff
changeset
|
586 |
26526
b7438760079b
* callproc.c (strerror): Remove decl.
Paul Eggert <eggert@twinsun.com>
parents:
26088
diff
changeset
|
587 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
|
588 signame = strsignal (code); |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25646
diff
changeset
|
589 |
13931
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
590 if (signame == 0) |
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
591 signame = "unknown"; |
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
592 |
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
593 synch_process_death = signame; |
c80fb27c183b
(win32_wait): fixed bad synch_process_retcode
Geoff Voelker <voelker@cs.washington.edu>
parents:
13425
diff
changeset
|
594 } |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
595 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
596 reap_subprocess (cp); |
9907 | 597 } |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
598 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
599 reap_subprocess (cp); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
600 |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
601 return pid; |
9907 | 602 } |
603 | |
78168
5d5dea23e4fd
(IMAGE_NT_OPTIONAL_HDR32_MAGIC, IMAGE_OPTIONAL_HEADER32): Define
Eli Zaretskii <eliz@gnu.org>
parents:
78164
diff
changeset
|
604 /* Old versions of w32api headers don't have separate 32-bit and |
5d5dea23e4fd
(IMAGE_NT_OPTIONAL_HDR32_MAGIC, IMAGE_OPTIONAL_HEADER32): Define
Eli Zaretskii <eliz@gnu.org>
parents:
78164
diff
changeset
|
605 64-bit defines, but the one they have matches the 32-bit variety. */ |
5d5dea23e4fd
(IMAGE_NT_OPTIONAL_HDR32_MAGIC, IMAGE_OPTIONAL_HEADER32): Define
Eli Zaretskii <eliz@gnu.org>
parents:
78164
diff
changeset
|
606 #ifndef IMAGE_NT_OPTIONAL_HDR32_MAGIC |
5d5dea23e4fd
(IMAGE_NT_OPTIONAL_HDR32_MAGIC, IMAGE_OPTIONAL_HEADER32): Define
Eli Zaretskii <eliz@gnu.org>
parents:
78164
diff
changeset
|
607 # define IMAGE_NT_OPTIONAL_HDR32_MAGIC IMAGE_NT_OPTIONAL_HDR_MAGIC |
5d5dea23e4fd
(IMAGE_NT_OPTIONAL_HDR32_MAGIC, IMAGE_OPTIONAL_HEADER32): Define
Eli Zaretskii <eliz@gnu.org>
parents:
78164
diff
changeset
|
608 # define IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER |
5d5dea23e4fd
(IMAGE_NT_OPTIONAL_HDR32_MAGIC, IMAGE_OPTIONAL_HEADER32): Define
Eli Zaretskii <eliz@gnu.org>
parents:
78164
diff
changeset
|
609 #endif |
5d5dea23e4fd
(IMAGE_NT_OPTIONAL_HDR32_MAGIC, IMAGE_OPTIONAL_HEADER32): Define
Eli Zaretskii <eliz@gnu.org>
parents:
78164
diff
changeset
|
610 |
110975
e0ac9a58795e
src/w32*.c: Make functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110431
diff
changeset
|
611 static void |
109152
e27859da5624
src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
108888
diff
changeset
|
612 w32_executable_type (char * filename, |
e27859da5624
src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
108888
diff
changeset
|
613 int * is_dos_app, |
e27859da5624
src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
108888
diff
changeset
|
614 int * is_cygnus_app, |
e27859da5624
src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
108888
diff
changeset
|
615 int * is_gui_app) |
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 file_data executable; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
618 char * p; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
619 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
620 /* Default values in case we can't tell for sure. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
621 *is_dos_app = FALSE; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
622 *is_cygnus_app = FALSE; |
38022
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
623 *is_gui_app = FALSE; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
624 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
625 if (!open_input_file (&executable, filename)) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
626 return; |
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 p = strrchr (filename, '.'); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
629 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
630 /* We can only identify DOS .com programs from the extension. */ |
95219
72c67a7befd5
* dispextern.h, xfaces.c (xstrcasecmp): Renamed from xstricmp.
Jason Rumney <jasonr@gnu.org>
parents:
94963
diff
changeset
|
631 if (p && xstrcasecmp (p, ".com") == 0) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
632 *is_dos_app = TRUE; |
95219
72c67a7befd5
* dispextern.h, xfaces.c (xstrcasecmp): Renamed from xstricmp.
Jason Rumney <jasonr@gnu.org>
parents:
94963
diff
changeset
|
633 else if (p && (xstrcasecmp (p, ".bat") == 0 |
72c67a7befd5
* dispextern.h, xfaces.c (xstrcasecmp): Renamed from xstricmp.
Jason Rumney <jasonr@gnu.org>
parents:
94963
diff
changeset
|
634 || xstrcasecmp (p, ".cmd") == 0)) |
15247
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
635 { |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
636 /* 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
|
637 accept this (somewhat surprisingly); presumably it looks at |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
638 COMSPEC to determine what executable to actually invoke. |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
639 Therefore, we have to do the same here as well. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
640 /* Actually, I think it uses the program association for that |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
641 extension, which is defined in the registry. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
642 p = egetenv ("COMSPEC"); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
643 if (p) |
38022
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
644 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
|
645 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
646 else |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
647 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
648 /* 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
|
649 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
|
650 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
|
651 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
|
652 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
653 IMAGE_DOS_HEADER * dos_header; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
654 IMAGE_NT_HEADERS * nt_header; |
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 dos_header = (PIMAGE_DOS_HEADER) executable.file_base; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
657 if (dos_header->e_magic != IMAGE_DOS_SIGNATURE) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
658 goto unwind; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
659 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
660 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
|
661 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
662 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
|
663 { |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
664 /* Some dos headers (pkunzip) have bogus e_lfanew fields. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
665 *is_dos_app = TRUE; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
666 } |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
667 else if (nt_header->Signature != IMAGE_NT_SIGNATURE |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
668 && LOWORD (nt_header->Signature) != IMAGE_OS2_SIGNATURE) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
669 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
670 *is_dos_app = TRUE; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
671 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
672 else if (nt_header->Signature == IMAGE_NT_SIGNATURE) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
673 { |
78164
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
674 IMAGE_DATA_DIRECTORY *data_dir = NULL; |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
675 if (nt_header->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
676 { |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
677 /* Ensure we are using the 32 bit structure. */ |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
678 IMAGE_OPTIONAL_HEADER32 *opt |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
679 = (IMAGE_OPTIONAL_HEADER32*) &(nt_header->OptionalHeader); |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
680 data_dir = opt->DataDirectory; |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
681 *is_gui_app = (opt->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI); |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
682 } |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
683 /* MingW 3.12 has the required 64 bit structs, but in case older |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
684 versions don't, only check 64 bit exes if we know how. */ |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
685 #ifdef IMAGE_NT_OPTIONAL_HDR64_MAGIC |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
686 else if (nt_header->OptionalHeader.Magic |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
687 == IMAGE_NT_OPTIONAL_HDR64_MAGIC) |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
688 { |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
689 IMAGE_OPTIONAL_HEADER64 *opt |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
690 = (IMAGE_OPTIONAL_HEADER64*) &(nt_header->OptionalHeader); |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
691 data_dir = opt->DataDirectory; |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
692 *is_gui_app = (opt->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI); |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
693 } |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
694 #endif |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
695 if (data_dir) |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
696 { |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
697 /* Look for cygwin.dll in DLL import list. */ |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
698 IMAGE_DATA_DIRECTORY import_dir = |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
699 data_dir[IMAGE_DIRECTORY_ENTRY_IMPORT]; |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
700 IMAGE_IMPORT_DESCRIPTOR * imports; |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
701 IMAGE_SECTION_HEADER * section; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
702 |
78164
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
703 section = rva_to_section (import_dir.VirtualAddress, nt_header); |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
704 imports = RVA_TO_PTR (import_dir.VirtualAddress, section, |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
705 executable); |
38022
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
706 |
78164
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
707 for ( ; imports->Name; imports++) |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
708 { |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
709 char * dllname = RVA_TO_PTR (imports->Name, section, |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
710 executable); |
100062
d4660dbaa550
* w32proc.c (Fw32_get_locale_info): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
100045
diff
changeset
|
711 |
78164
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
712 /* The exact name of the cygwin dll has changed with |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
713 various releases, but hopefully this will be reasonably |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
714 future proof. */ |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
715 if (strncmp (dllname, "cygwin", 6) == 0) |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
716 { |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
717 *is_cygnus_app = TRUE; |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
718 break; |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
719 } |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
720 } |
d9f9dda7474c
(w32_executable_type): Handle 64 bit executables.
Jason Rumney <jasonr@gnu.org>
parents:
75348
diff
changeset
|
721 } |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
722 } |
15247
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
723 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
724 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
725 unwind: |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
726 close_file_data (&executable); |
15247
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
727 } |
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
728 |
110975
e0ac9a58795e
src/w32*.c: Make functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110431
diff
changeset
|
729 static int |
31115
42753ce203f8
(IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents:
26526
diff
changeset
|
730 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
|
731 { |
31115
42753ce203f8
(IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents:
26526
diff
changeset
|
732 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
|
733 |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
734 while (*str1 && *str2 && *str1 != '=' && *str2 != '=') |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
735 { |
31354
547138676a74
(compare_env): Convert to uppercase for comparison,
Andrew Innes <andrewi@gnu.org>
parents:
31115
diff
changeset
|
736 /* 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
|
737 names, so do the same here. */ |
547138676a74
(compare_env): Convert to uppercase for comparison,
Andrew Innes <andrewi@gnu.org>
parents:
31115
diff
changeset
|
738 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
|
739 return 1; |
31354
547138676a74
(compare_env): Convert to uppercase for comparison,
Andrew Innes <andrewi@gnu.org>
parents:
31115
diff
changeset
|
740 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
|
741 return -1; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
742 str1++, str2++; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
743 } |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
744 |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
745 if (*str1 == '=' && *str2 == '=') |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
746 return 0; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
747 else if (*str1 == '=') |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
748 return -1; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
749 else |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
750 return 1; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
751 } |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
752 |
110975
e0ac9a58795e
src/w32*.c: Make functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110431
diff
changeset
|
753 static void |
16826
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
754 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
|
755 { |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
756 char **optr, **nptr; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
757 int num; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
758 |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
759 nptr = new_envp; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
760 optr = envp1; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
761 while (*optr) |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
762 *nptr++ = *optr++; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
763 num = optr - envp1; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
764 |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
765 optr = envp2; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
766 while (*optr) |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
767 *nptr++ = *optr++; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
768 num += optr - envp2; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
769 |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
770 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
|
771 |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
772 *nptr = NULL; |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
773 } |
9907 | 774 |
775 /* When a new child process is created we need to register it in our list, | |
776 so intercept spawn requests. */ | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
777 int |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
778 sys_spawnve (int mode, char *cmdname, char **argv, char **envp) |
9907 | 779 { |
12239
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
780 Lisp_Object program, full; |
9907 | 781 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
|
782 int arglen, numenv; |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
783 int pid; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
784 child_process *cp; |
38022
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
785 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
|
786 int do_quoting = 0; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
787 char escape_char; |
16826
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
788 /* 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
|
789 variable in their environment. */ |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
790 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
|
791 char *extra_env[] = {ppid_env_var_buffer, NULL}; |
79490
217ec3ada789
(sys_spawnve): Quote args with wildcards.
Jason Rumney <jasonr@gnu.org>
parents:
78726
diff
changeset
|
792 /* These are the characters that cause an argument to need quoting. |
217ec3ada789
(sys_spawnve): Quote args with wildcards.
Jason Rumney <jasonr@gnu.org>
parents:
78726
diff
changeset
|
793 Arguments with whitespace characters need quoting to prevent the |
217ec3ada789
(sys_spawnve): Quote args with wildcards.
Jason Rumney <jasonr@gnu.org>
parents:
78726
diff
changeset
|
794 argument being split into two or more. Arguments with wildcards |
217ec3ada789
(sys_spawnve): Quote args with wildcards.
Jason Rumney <jasonr@gnu.org>
parents:
78726
diff
changeset
|
795 are also quoted, for consistency with posix platforms, where wildcards |
217ec3ada789
(sys_spawnve): Quote args with wildcards.
Jason Rumney <jasonr@gnu.org>
parents:
78726
diff
changeset
|
796 are not expanded if we run the program directly without a shell. |
217ec3ada789
(sys_spawnve): Quote args with wildcards.
Jason Rumney <jasonr@gnu.org>
parents:
78726
diff
changeset
|
797 Some extra whitespace characters need quoting in Cygwin programs, |
217ec3ada789
(sys_spawnve): Quote args with wildcards.
Jason Rumney <jasonr@gnu.org>
parents:
78726
diff
changeset
|
798 so this list is conditionally modified below. */ |
217ec3ada789
(sys_spawnve): Quote args with wildcards.
Jason Rumney <jasonr@gnu.org>
parents:
78726
diff
changeset
|
799 char *sepchars = " \t*?"; |
16826
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
800 |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
801 /* 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
|
802 if (mode != _P_NOWAIT) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
803 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
804 errno = EINVAL; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
805 return -1; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
806 } |
12239
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
807 |
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
808 /* 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
|
809 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
|
810 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
|
811 { |
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
812 struct gcpro gcpro1; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
813 |
12239
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
814 full = Qnil; |
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
815 GCPRO1 (program); |
45008
07245ba4ebcc
(sys_spawnve): Update call to openp.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
44928
diff
changeset
|
816 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
|
817 UNGCPRO; |
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
818 if (NILP (full)) |
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
819 { |
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
820 errno = EINVAL; |
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
821 return -1; |
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
822 } |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
823 program = full; |
12239
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
824 } |
ff7738cdbd99
(win32_spawnve): Accept program names without executable suffixes.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
825 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
826 /* 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
|
827 cmdname = SDATA (program); |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
828 unixtodos_filename (cmdname); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
829 argv[0] = cmdname; |
15247
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
830 |
21613
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
831 /* 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
|
832 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
|
833 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
|
834 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
|
835 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
|
836 |
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
837 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
|
838 initial window unless specifically requested. */ |
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
839 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
|
840 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
841 /* 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
|
842 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
|
843 while leaving the real app name as argv[0]. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
844 if (is_dos_app) |
15247
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
845 { |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
846 cmdname = alloca (MAXPATHLEN); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
847 if (egetenv ("CMDPROXY")) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
848 strcpy (cmdname, egetenv ("CMDPROXY")); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
849 else |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
850 { |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
45089
diff
changeset
|
851 strcpy (cmdname, SDATA (Vinvocation_directory)); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
852 strcat (cmdname, "cmdproxy.exe"); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
853 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
854 unixtodos_filename (cmdname); |
15247
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
855 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
856 |
9907 | 857 /* we have to do some conjuring here to put argv and envp into the |
858 form CreateProcess wants... argv needs to be a space separated/null | |
859 terminated list of parameters, and envp is a null | |
860 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
|
861 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
862 Additionally, zero-length args and args containing whitespace or |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
863 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
|
864 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
|
865 the child process reconstructs the argv array we start with |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
866 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
|
867 as embedded quotes. |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
868 |
21613
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
869 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
|
870 them, while MSVC uses backslash for escaping. (Actually the MSVC |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
871 startup code does attempt to recognise doubled quotes and accept |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
872 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
|
873 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
|
874 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
|
875 binary is apparently a Cygnus compiled app. |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
876 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
877 Note that using backslash to escape embedded quotes requires |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
878 additional special handling if an embedded quote is already |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
879 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
|
880 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
|
881 doubled. For consistency, we apply this special handling as long |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
882 as the escape character is not quote. |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
883 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
884 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
|
885 figure out list lengths on the fly and allocate them. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
886 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
887 if (!NILP (Vw32_quote_process_args)) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
888 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
889 do_quoting = 1; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
890 /* Override escape char by binding w32-quote-process-args to |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
891 desired character, or use t for auto-selection. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
892 if (INTEGERP (Vw32_quote_process_args)) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
893 escape_char = XINT (Vw32_quote_process_args); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
894 else |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
895 escape_char = is_cygnus_app ? '"' : '\\'; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
896 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
897 |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
898 /* Cygwin apps needs quoting a bit more often. */ |
37290
6e6e46d239df
(sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents:
33694
diff
changeset
|
899 if (escape_char == '"') |
6e6e46d239df
(sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents:
33694
diff
changeset
|
900 sepchars = "\r\n\t\f '"; |
6e6e46d239df
(sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents:
33694
diff
changeset
|
901 |
9907 | 902 /* do argv... */ |
903 arglen = 0; | |
904 targ = argv; | |
905 while (*targ) | |
906 { | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
907 char * p = *targ; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
908 int need_quotes = 0; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
909 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
|
910 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
911 if (*p == 0) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
912 need_quotes = 1; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
913 for ( ; *p; p++) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
914 { |
37290
6e6e46d239df
(sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents:
33694
diff
changeset
|
915 if (escape_char == '"' && *p == '\\') |
6e6e46d239df
(sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents:
33694
diff
changeset
|
916 /* 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
|
917 arglen++; |
6e6e46d239df
(sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents:
33694
diff
changeset
|
918 else if (*p == '"') |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
919 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
920 /* allow for embedded quotes to be escaped */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
921 arglen++; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
922 need_quotes = 1; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
923 /* handle the case where the embedded quote is already escaped */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
924 if (escape_char_run > 0) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
925 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
926 /* To preserve the arg exactly, we need to double the |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
927 preceding escape characters (plus adding one to |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
928 escape the quote character itself). */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
929 arglen += escape_char_run; |
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 } |
37290
6e6e46d239df
(sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents:
33694
diff
changeset
|
932 else if (strchr (sepchars, *p) != NULL) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
933 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
934 need_quotes = 1; |
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 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
937 if (*p == escape_char && escape_char != '"') |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
938 escape_char_run++; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
939 else |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
940 escape_char_run = 0; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
941 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
942 if (need_quotes) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
943 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
944 arglen += 2; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
945 /* 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
|
946 must not let the enclosing quote be escaped. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
947 if (escape_char_run > 0) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
948 arglen += escape_char_run; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
949 } |
9907 | 950 arglen += strlen (*targ++) + 1; |
951 } | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
952 cmdline = alloca (arglen); |
9907 | 953 targ = argv; |
954 parg = cmdline; | |
955 while (*targ) | |
956 { | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
957 char * p = *targ; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
958 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
|
959 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
960 if (*p == 0) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
961 need_quotes = 1; |
15201
43551ec4b69d
(Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15145
diff
changeset
|
962 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
963 if (do_quoting) |
15201
43551ec4b69d
(Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15145
diff
changeset
|
964 { |
43551ec4b69d
(Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15145
diff
changeset
|
965 for ( ; *p; p++) |
37290
6e6e46d239df
(sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents:
33694
diff
changeset
|
966 if ((strchr (sepchars, *p) != NULL) || *p == '"') |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
967 need_quotes = 1; |
15201
43551ec4b69d
(Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15145
diff
changeset
|
968 } |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
969 if (need_quotes) |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
970 { |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
971 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
|
972 char * first; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
973 char * last; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
974 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
975 p = *targ; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
976 first = p; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
977 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
|
978 *parg++ = '"'; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
979 #if 0 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
980 /* 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
|
981 beginning or end of the arg - this could lead to incorrect |
96376
c3309dba6542
American English spelling fix.
Glenn Morris <rgm@gnu.org>
parents:
96361
diff
changeset
|
982 behavior when the arg itself represents a command line |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
983 containing quoted args. I believe this was originally done |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
984 as a hack to make some things work, before |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
985 `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
|
986 while (*p) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
987 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
988 if (*p == '"' && p > first && p < last) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
989 *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
|
990 *parg++ = *p++; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
991 } |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
992 #else |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
993 for ( ; *p; p++) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
994 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
995 if (*p == '"') |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
996 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
997 /* double preceding escape chars if any */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
998 while (escape_char_run > 0) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
999 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1000 *parg++ = escape_char; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1001 escape_char_run--; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1002 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1003 /* escape all quote chars, even at beginning or end */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1004 *parg++ = escape_char; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1005 } |
37290
6e6e46d239df
(sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents:
33694
diff
changeset
|
1006 else if (escape_char == '"' && *p == '\\') |
6e6e46d239df
(sys_spawnve): Quote more chars for Cygwin.
Gerd Moellmann <gerd@gnu.org>
parents:
33694
diff
changeset
|
1007 *parg++ = '\\'; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1008 *parg++ = *p; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1009 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1010 if (*p == escape_char && escape_char != '"') |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1011 escape_char_run++; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1012 else |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1013 escape_char_run = 0; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1014 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1015 /* double escape chars before enclosing quote */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1016 while (escape_char_run > 0) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1017 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1018 *parg++ = escape_char; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1019 escape_char_run--; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1020 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1021 #endif |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1022 *parg++ = '"'; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1023 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1024 else |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1025 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1026 strcpy (parg, *targ); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1027 parg += strlen (*targ); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1028 } |
9907 | 1029 *parg++ = ' '; |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1030 targ++; |
9907 | 1031 } |
1032 *--parg = '\0'; | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
1033 |
9907 | 1034 /* and envp... */ |
1035 arglen = 1; | |
1036 targ = envp; | |
16826
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
1037 numenv = 1; /* for end null */ |
9907 | 1038 while (*targ) |
1039 { | |
1040 arglen += strlen (*targ++) + 1; | |
16826
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
1041 numenv++; |
9907 | 1042 } |
16826
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
1043 /* extra env vars... */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
1044 sprintf (ppid_env_var_buffer, "EM_PARENT_PROCESS_ID=%d", |
9907 | 1045 GetCurrentProcessId ()); |
1046 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
|
1047 numenv++; |
9907 | 1048 |
16826
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
1049 /* 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
|
1050 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
|
1051 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
|
1052 |
e7ad34b65d8e
(compare_env, merge_and_sort_env): New functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
1053 /* concatenate env entries. */ |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1054 env = alloca (arglen); |
9907 | 1055 parg = env; |
1056 while (*targ) | |
1057 { | |
1058 strcpy (parg, *targ); | |
1059 parg += strlen (*targ++); | |
1060 *parg++ = '\0'; | |
1061 } | |
1062 *parg++ = '\0'; | |
1063 *parg = '\0'; | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1064 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1065 cp = new_child (); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1066 if (cp == NULL) |
9907 | 1067 { |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1068 errno = EAGAIN; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1069 return -1; |
9907 | 1070 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
1071 |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1072 /* Now create the process. */ |
38022
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
1073 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
|
1074 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1075 delete_child (cp); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1076 errno = ENOEXEC; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1077 return -1; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1078 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
1079 |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1080 return pid; |
9907 | 1081 } |
1082 | |
1083 /* Emulate the select call | |
1084 Wait for available input on any of the given rfds, or timeout if | |
1085 a timeout is given and no input is detected | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1086 wfds and efds are not supported and must be NULL. |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1087 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1088 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
|
1089 synchronously call the SIGCHLD handler. Since it is possible for |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1090 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
|
1091 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
|
1092 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
|
1093 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
|
1094 |
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1095 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
|
1096 C-g is not able to interrupt it, we always wait on interrupt_handle |
96361
a99299e4d2de
American English spelling fix.
Glenn Morris <rgm@gnu.org>
parents:
95277
diff
changeset
|
1097 (which is signaled by the input thread when C-g is detected). If we |
22079
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1098 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
|
1099 EINTR as on Unix. */ |
9907 | 1100 |
1101 /* From ntterm.c */ | |
1102 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
|
1103 |
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1104 /* From w32xfns.c */ |
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1105 extern HANDLE interrupt_handle; |
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1106 |
9907 | 1107 /* From process.c */ |
1108 extern int proc_buffered_char[]; | |
1109 | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
1110 int |
11388
96fa39ad9403
(win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
1111 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
|
1112 EMACS_TIME *timeout) |
9907 | 1113 { |
1114 SELECT_TYPE orfds; | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1115 DWORD timeout_ms, start_time; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1116 int i, nh, nc, nr; |
9907 | 1117 DWORD active; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1118 child_process *cp, *cps[MAX_CHILDREN]; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1119 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
|
1120 int fdindex[MAXDESC]; /* mapping from wait handles back to descriptors */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
1121 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1122 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
|
1123 |
9907 | 1124 /* If the descriptor sets are NULL but timeout isn't, then just Sleep. */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
1125 if (rfds == NULL && wfds == NULL && efds == NULL && timeout != NULL) |
9907 | 1126 { |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1127 Sleep (timeout_ms); |
9907 | 1128 return 0; |
1129 } | |
1130 | |
1131 /* Otherwise, we only handle rfds, so fail otherwise. */ | |
1132 if (rfds == NULL || wfds != NULL || efds != NULL) | |
1133 { | |
1134 errno = EINVAL; | |
1135 return -1; | |
1136 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
1137 |
9907 | 1138 orfds = *rfds; |
1139 FD_ZERO (rfds); | |
1140 nr = 0; | |
22079
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1141 |
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1142 /* 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
|
1143 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
|
1144 fdindex[0] = -1; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
1145 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1146 /* 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
|
1147 nh = 1; |
9907 | 1148 for (i = 0; i < nfds; i++) |
1149 if (FD_ISSET (i, &orfds)) | |
1150 { | |
1151 if (i == 0) | |
1152 { | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1153 if (keyboard_handle) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1154 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1155 /* Handle stdin specially */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1156 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
|
1157 fdindex[nh] = i; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1158 nh++; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1159 } |
9907 | 1160 |
1161 /* Check for any emacs-generated input in the queue since | |
1162 it won't be detected in the wait */ | |
1163 if (detect_input_pending ()) | |
1164 { | |
1165 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
|
1166 return 1; |
9907 | 1167 } |
1168 } | |
1169 else | |
1170 { | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1171 /* 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
|
1172 cp = fd_info[i].cp; |
9907 | 1173 if (cp) |
1174 { | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1175 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
|
1176 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1177 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
|
1178 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1179 /* 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
|
1180 cp->fd = i; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1181 /* 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
|
1182 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
|
1183 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
|
1184 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
|
1185 "%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
|
1186 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1187 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1188 #ifdef CHECK_INTERLOCK |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1189 /* 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
|
1190 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1191 current_status = cp->status; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1192 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
|
1193 { |
96361
a99299e4d2de
American English spelling fix.
Glenn Morris <rgm@gnu.org>
parents:
95277
diff
changeset
|
1194 /* char_avail has been signaled, so status (which may |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1195 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
|
1196 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
|
1197 current_status = cp->status; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1198 if (current_status != STATUS_READ_SUCCEEDED |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1199 && 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
|
1200 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
|
1201 current_status)); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1202 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1203 else |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1204 { |
96361
a99299e4d2de
American English spelling fix.
Glenn Morris <rgm@gnu.org>
parents:
95277
diff
changeset
|
1205 /* char_avail has not been signaled, so status should |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1206 indicate that read is in progress; small possibility |
96361
a99299e4d2de
American English spelling fix.
Glenn Morris <rgm@gnu.org>
parents:
95277
diff
changeset
|
1207 that read has completed but event wasn't yet signaled |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1208 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
|
1209 or if running on separate CPUs). */ |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1210 if (current_status != STATUS_READ_READY |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1211 && current_status != STATUS_READ_IN_PROGRESS |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1212 && current_status != STATUS_READ_SUCCEEDED |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1213 && 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
|
1214 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
|
1215 current_status)); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1216 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1217 #endif |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1218 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
|
1219 fdindex[nh] = i; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1220 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
|
1221 nh++; |
9907 | 1222 #ifdef FULL_DEBUG |
1223 DebPrint (("select waiting on child %d fd %d\n", | |
1224 cp-child_procs, i)); | |
1225 #endif | |
1226 } | |
1227 else | |
1228 { | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1229 /* 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
|
1230 |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1231 /* 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
|
1232 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
|
1233 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
|
1234 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
|
1235 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
|
1236 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
|
1237 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
|
1238 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
|
1239 |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1240 DebPrint (("sys_select: fd %ld is invalid! ignoring\n", i)); |
9907 | 1241 } |
1242 } | |
1243 } | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1244 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1245 count_children: |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1246 /* Add handles of child processes. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1247 nc = 0; |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
1248 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
|
1249 /* 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
|
1250 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
|
1251 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
|
1252 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
|
1253 && (cp->fd < 0 |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1254 || (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
|
1255 || (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
|
1256 ) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1257 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1258 wait_hnd[nh + nc] = cp->procinfo.hProcess; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1259 cps[nc] = cp; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1260 nc++; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1261 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
1262 |
9907 | 1263 /* Nothing to look for, so we didn't find anything */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
1264 if (nh + nc == 0) |
9907 | 1265 { |
11388
96fa39ad9403
(win32_wait): Reap synchronous subprocesses, and place
Karl Heuer <kwzh@gnu.org>
parents:
9907
diff
changeset
|
1266 if (timeout) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1267 Sleep (timeout_ms); |
9907 | 1268 return 0; |
1269 } | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
1270 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1271 start_time = GetTickCount (); |
24915
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1272 |
96361
a99299e4d2de
American English spelling fix.
Glenn Morris <rgm@gnu.org>
parents:
95277
diff
changeset
|
1273 /* Wait for input or child death to be signaled. If user input is |
24915
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1274 allowed, then also accept window messages. */ |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1275 if (FD_ISSET (0, &orfds)) |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1276 active = MsgWaitForMultipleObjects (nh + nc, wait_hnd, FALSE, timeout_ms, |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1277 QS_ALLINPUT); |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1278 else |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1279 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
|
1280 |
9907 | 1281 if (active == WAIT_FAILED) |
1282 { | |
1283 DebPrint (("select.WaitForMultipleObjects (%d, %lu) failed with %lu\n", | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1284 nh + nc, timeout_ms, GetLastError ())); |
56729
e6e0caa7ec87
Rename wait_reading_process_input to wait_reading_process_output.
Kim F. Storm <storm@cua.dk>
parents:
55674
diff
changeset
|
1285 /* don't return EBADF - this causes wait_reading_process_output to |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1286 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
|
1287 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
|
1288 possibly at other times. */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1289 errno = EINTR; |
9907 | 1290 return -1; |
1291 } | |
1292 else if (active == WAIT_TIMEOUT) | |
1293 { | |
1294 return 0; | |
1295 } | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1296 else if (active >= WAIT_OBJECT_0 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1297 && active < WAIT_OBJECT_0+MAXIMUM_WAIT_OBJECTS) |
9907 | 1298 { |
1299 active -= WAIT_OBJECT_0; | |
1300 } | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1301 else if (active >= WAIT_ABANDONED_0 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1302 && active < WAIT_ABANDONED_0+MAXIMUM_WAIT_OBJECTS) |
9907 | 1303 { |
1304 active -= WAIT_ABANDONED_0; | |
1305 } | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1306 else |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1307 abort (); |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1308 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1309 /* Loop over all handles after active (now officially documented as |
96361
a99299e4d2de
American English spelling fix.
Glenn Morris <rgm@gnu.org>
parents:
95277
diff
changeset
|
1310 being the first signaled handle in the array). We do this to |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1311 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
|
1312 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
|
1313 do |
9907 | 1314 { |
24915
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1315 if (active == nh + nc) |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1316 { |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1317 /* 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
|
1318 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
|
1319 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
|
1320 further messages arrive. |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1321 |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1322 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
|
1323 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
|
1324 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
|
1325 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
|
1326 for modeless dialogs created by lisp (ie. to register |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1327 window handles to pass to IsDialogMessage). |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1328 |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1329 (*) Note that MsgWaitForMultipleObjects above is an |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1330 internal dispatch point for messages that are sent to |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1331 windows created by this thread. */ |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1332 drain_message_queue (); |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1333 } |
ff85091a55e7
(sys_select): Call MsgWaitForMultipleObjects instead
Andrew Innes <andrewi@gnu.org>
parents:
24671
diff
changeset
|
1334 else if (active >= nh) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1335 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1336 cp = cps[active - nh]; |
21613
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1337 |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1338 /* 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
|
1339 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
|
1340 SIGCHLD until we do. */ |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1341 |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1342 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
|
1343 fd_info[cp->fd].flags |= FILE_SEND_SIGCHLD; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1344 /* 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
|
1345 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
|
1346 sig_handlers[SIGCHLD] != SIG_IGN) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1347 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1348 #ifdef FULL_DEBUG |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1349 DebPrint (("select calling SIGCHLD handler for pid %d\n", |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1350 cp->pid)); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1351 #endif |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1352 dead_child = cp; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1353 sig_handlers[SIGCHLD] (SIGCHLD); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1354 dead_child = NULL; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1355 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1356 } |
22079
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1357 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
|
1358 { |
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1359 /* 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
|
1360 errno = EINTR; |
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1361 return -1; |
b7a2370ee82d
(sys_select): Always wait on interrupt_handle, so that
Richard M. Stallman <rms@gnu.org>
parents:
21742
diff
changeset
|
1362 } |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1363 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
|
1364 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1365 /* Keyboard input available */ |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1366 FD_SET (0, rfds); |
9907 | 1367 nr++; |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1368 } |
9907 | 1369 else |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1370 { |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1371 /* must be a socket or pipe - read ahead should have |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1372 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
|
1373 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
|
1374 nr++; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1375 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1376 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1377 /* 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
|
1378 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
|
1379 all children that have died. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1380 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
|
1381 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
|
1382 break; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1383 } while (active < nh + nc); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1384 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1385 /* 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
|
1386 if (nr == 0) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1387 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1388 DWORD elapsed = GetTickCount () - start_time; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1389 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1390 if (timeout_ms > elapsed) /* INFINITE is MAX_UINT */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1391 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1392 if (timeout_ms != INFINITE) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1393 timeout_ms -= elapsed; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1394 goto count_children; |
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 } |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1397 |
9907 | 1398 return nr; |
1399 } | |
1400 | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1401 /* Substitute for certain kill () operations */ |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1402 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1403 static BOOL CALLBACK |
31115
42753ce203f8
(IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents:
26526
diff
changeset
|
1404 find_child_console (HWND hwnd, LPARAM arg) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1405 { |
31115
42753ce203f8
(IsValidLocale): Extern missing from mingw32 headers.
Andrew Innes <andrewi@gnu.org>
parents:
26526
diff
changeset
|
1406 child_process * cp = (child_process *) arg; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1407 DWORD thread_id; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1408 DWORD process_id; |
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 thread_id = GetWindowThreadProcessId (hwnd, &process_id); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1411 if (process_id == cp->procinfo.dwProcessId) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1412 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1413 char window_class[32]; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1414 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1415 GetClassName (hwnd, window_class, sizeof (window_class)); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1416 if (strcmp (window_class, |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1417 (os_subtype == OS_WIN95) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1418 ? "tty" |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1419 : "ConsoleWindowClass") == 0) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1420 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1421 cp->hwnd = hwnd; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1422 return FALSE; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1423 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1424 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1425 /* keep looking */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1426 return TRUE; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1427 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1428 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
1429 int |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1430 sys_kill (int pid, int sig) |
9907 | 1431 { |
1432 child_process *cp; | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1433 HANDLE proc_hand; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1434 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
|
1435 int rc = 0; |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
1436 |
9907 | 1437 /* Only handle signals that will result in the process dying */ |
1438 if (sig != SIGINT && sig != SIGKILL && sig != SIGQUIT && sig != SIGHUP) | |
1439 { | |
1440 errno = EINVAL; | |
1441 return -1; | |
1442 } | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1443 |
9907 | 1444 cp = find_child_pid (pid); |
1445 if (cp == NULL) | |
1446 { | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1447 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
|
1448 if (proc_hand == NULL) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1449 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1450 errno = EPERM; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1451 return -1; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1452 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1453 need_to_free = 1; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1454 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1455 else |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1456 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1457 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
|
1458 pid = cp->procinfo.dwProcessId; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1459 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1460 /* Try to locate console window for process. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1461 EnumWindows (find_child_console, (LPARAM) cp); |
9907 | 1462 } |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
1463 |
38022
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
1464 if (sig == SIGINT || sig == SIGQUIT) |
9907 | 1465 { |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1466 if (NILP (Vw32_start_process_share_console) && cp && cp->hwnd) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1467 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1468 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
|
1469 /* 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
|
1470 BYTE vk_break_code = (sig == SIGINT) ? 'C' : VK_CANCEL; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1471 BYTE break_scan_code = (BYTE) MapVirtualKey (vk_break_code, 0); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1472 HWND foreground_window; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1473 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1474 if (break_scan_code == 0) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1475 { |
38022
71e8b6ae114f
(create_child): Add new parameter is_gui_app.
Andrew Innes <andrewi@gnu.org>
parents:
37703
diff
changeset
|
1476 /* 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
|
1477 vk_break_code = 'C'; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1478 break_scan_code = (BYTE) MapVirtualKey (vk_break_code, 0); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1479 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1480 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1481 foreground_window = GetForegroundWindow (); |
24671
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1482 if (foreground_window) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1483 { |
24671
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1484 /* 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
|
1485 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
|
1486 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
|
1487 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
|
1488 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
|
1489 foreground window. */ |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1490 DWORD foreground_thread, child_thread; |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1491 foreground_thread = |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1492 GetWindowThreadProcessId (foreground_window, NULL); |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1493 if (foreground_thread == GetCurrentThreadId () |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1494 || !AttachThreadInput (GetCurrentThreadId (), |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1495 foreground_thread, TRUE)) |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1496 foreground_thread = 0; |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1497 |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1498 child_thread = GetWindowThreadProcessId (cp->hwnd, NULL); |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1499 if (child_thread == GetCurrentThreadId () |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1500 || !AttachThreadInput (GetCurrentThreadId (), |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1501 child_thread, TRUE)) |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1502 child_thread = 0; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1503 |
24671
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1504 /* Set the foreground window to the child. */ |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1505 if (SetForegroundWindow (cp->hwnd)) |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1506 { |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1507 /* 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
|
1508 Ctrl-C. */ |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1509 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
|
1510 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
|
1511 (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
|
1512 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
|
1513 (vk_break_code == 'C' ? 0 : KEYEVENTF_EXTENDEDKEY) |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1514 | KEYEVENTF_KEYUP, 0); |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1515 keybd_event (VK_CONTROL, control_scan_code, |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1516 KEYEVENTF_KEYUP, 0); |
21613
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1517 |
24671
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1518 /* 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
|
1519 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
|
1520 Sleep (100); |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1521 |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1522 SetForegroundWindow (foreground_window); |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1523 } |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1524 /* 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
|
1525 the foreground switching is over. */ |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1526 if (foreground_thread) |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1527 AttachThreadInput (GetCurrentThreadId (), |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1528 foreground_thread, FALSE); |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1529 if (child_thread) |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1530 AttachThreadInput (GetCurrentThreadId (), |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1531 child_thread, FALSE); |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1532 } |
65ebab3569e0
(sys_kill): Attach to current foreground thread
Andrew Innes <andrewi@gnu.org>
parents:
24105
diff
changeset
|
1533 } |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1534 /* Ctrl-Break is NT equivalent of SIGINT. */ |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1535 else if (!GenerateConsoleCtrlEvent (CTRL_BREAK_EVENT, pid)) |
9907 | 1536 { |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1537 DebPrint (("sys_kill.GenerateConsoleCtrlEvent return %d " |
9907 | 1538 "for pid %lu\n", GetLastError (), pid)); |
1539 errno = EINVAL; | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1540 rc = -1; |
21742
b1c3fe58dbbe
(sys_kill): Fix indenting.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21613
diff
changeset
|
1541 } |
9907 | 1542 } |
1543 else | |
1544 { | |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1545 if (NILP (Vw32_start_process_share_console) && cp && cp->hwnd) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1546 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1547 #if 1 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1548 if (os_subtype == OS_WIN95) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1549 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1550 /* |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1551 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
|
1552 calling the Shell VxD (id 0x17) V86 interface, function #4 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1553 "SHELL_Destroy_VM", ie. |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1554 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1555 mov edx,4 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1556 mov ebx,vm_handle |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1557 call shellapi |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1558 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1559 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
|
1560 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
|
1561 Switch_VM_and_callback). |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1562 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1563 Could try to invoke DestroyVM through CallVxD. |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1564 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1565 */ |
21613
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1566 #if 0 |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1567 /* 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
|
1568 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
|
1569 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
|
1570 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
|
1571 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
|
1572 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
|
1573 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
|
1574 doesn't freeze the 16-bit subsystem. */ |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1575 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
|
1576 #endif |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1577 if (!TerminateProcess (proc_hand, 0xff)) |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1578 { |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1579 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
|
1580 "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
|
1581 errno = EINVAL; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1582 rc = -1; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
1583 } |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1584 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1585 else |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1586 #endif |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1587 PostMessage (cp->hwnd, WM_CLOSE, 0, 0); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1588 } |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
1589 /* 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
|
1590 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
|
1591 used in every case. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1592 else if (!TerminateProcess (proc_hand, 0xff)) |
9907 | 1593 { |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1594 DebPrint (("sys_kill.TerminateProcess returned %d " |
9907 | 1595 "for pid %lu\n", GetLastError (), pid)); |
1596 errno = EINVAL; | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1597 rc = -1; |
9907 | 1598 } |
1599 } | |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1600 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1601 if (need_to_free) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1602 CloseHandle (proc_hand); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1603 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1604 return rc; |
9907 | 1605 } |
1606 | |
21452
bd9b548fd162
Delete incorrect prototype of report_file_error.
Karl Heuer <kwzh@gnu.org>
parents:
19712
diff
changeset
|
1607 /* 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
|
1608 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1609 /* 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
|
1610 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
|
1611 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1612 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
|
1613 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
|
1614 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1615 - 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
|
1616 - 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
|
1617 (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
|
1618 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
|
1619 - 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
|
1620 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
|
1621 - 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
|
1622 - 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
|
1623 (see reset_standard_handles) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1624 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
|
1625 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1626 void |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1627 prepare_standard_handles (int in, int out, int err, HANDLE handles[3]) |
9907 | 1628 { |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1629 HANDLE parent; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1630 HANDLE newstdin, newstdout, newstderr; |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1631 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1632 parent = GetCurrentProcess (); |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1633 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1634 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
|
1635 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
|
1636 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
|
1637 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1638 /* make inheritable copies of the new handles */ |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
1639 if (!DuplicateHandle (parent, |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1640 (HANDLE) _get_osfhandle (in), |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1641 parent, |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
1642 &newstdin, |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
1643 0, |
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
1644 TRUE, |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1645 DUPLICATE_SAME_ACCESS)) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1646 report_file_error ("Duplicating input handle for child", Qnil); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
1647 |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1648 if (!DuplicateHandle (parent, |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1649 (HANDLE) _get_osfhandle (out), |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1650 parent, |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1651 &newstdout, |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1652 0, |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1653 TRUE, |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1654 DUPLICATE_SAME_ACCESS)) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1655 report_file_error ("Duplicating output handle for child", Qnil); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
1656 |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1657 if (!DuplicateHandle (parent, |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1658 (HANDLE) _get_osfhandle (err), |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1659 parent, |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1660 &newstderr, |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1661 0, |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1662 TRUE, |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1663 DUPLICATE_SAME_ACCESS)) |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1664 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
|
1665 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1666 /* 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
|
1667 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
|
1668 report_file_error ("Changing stdin handle", Qnil); |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
1669 |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1670 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
|
1671 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
|
1672 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1673 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
|
1674 report_file_error ("Changing stderr handle", Qnil); |
9907 | 1675 } |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1676 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1677 void |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1678 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
|
1679 { |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1680 /* 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
|
1681 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
|
1682 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
|
1683 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
|
1684 |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1685 /* 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
|
1686 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
|
1687 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
|
1688 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
|
1689 } |
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
1690 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1691 void |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1692 set_process_dir (char * dir) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1693 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1694 process_dir = dir; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1695 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1696 |
15356
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1697 /* 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
|
1698 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
|
1699 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
|
1700 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
|
1701 first called. |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1702 |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1703 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
|
1704 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
|
1705 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
|
1706 socket services. */ |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1707 |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1708 /* From nt.c */ |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1709 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
|
1710 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
|
1711 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
|
1712 |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1713 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
|
1714 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
1715 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
|
1716 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
|
1717 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
|
1718 |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1719 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
|
1720 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
|
1721 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
|
1722 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
|
1723 returned to indicate winsock support is present. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109160
diff
changeset
|
1724 (Lisp_Object load_now) |
15356
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1725 { |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1726 int have_winsock; |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1727 |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1728 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
|
1729 if (have_winsock) |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1730 { |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1731 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
|
1732 { |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1733 /* 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
|
1734 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
|
1735 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
|
1736 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
|
1737 Lisp_Object hostname; |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1738 |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1739 init_system_name (); |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1740 hostname = Vsystem_name; |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1741 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
|
1742 return hostname; |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1743 } |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1744 return Qt; |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1745 } |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1746 return Qnil; |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1747 } |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1748 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
1749 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
|
1750 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
|
1751 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
|
1752 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
|
1753 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
|
1754 socket connections still exist. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109160
diff
changeset
|
1755 (void) |
15356
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1756 { |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1757 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
|
1758 } |
1a917c5d944c
(Fwin32_has_winsock, Fwin32_unload_winsock) [HAVE_SOCKETS]: New functions.
Richard M. Stallman <rms@gnu.org>
parents:
15351
diff
changeset
|
1759 |
15201
43551ec4b69d
(Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15145
diff
changeset
|
1760 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1761 /* Some miscellaneous functions that are Windows specific, but not GUI |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1762 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
|
1763 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1764 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
|
1765 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
|
1766 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
|
1767 All path elements in FILENAME are converted to their short names. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109160
diff
changeset
|
1768 (Lisp_Object filename) |
19712
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 char shortname[MAX_PATH]; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1771 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
39812
diff
changeset
|
1772 CHECK_STRING (filename); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1773 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1774 /* first expand it. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1775 filename = Fexpand_file_name (filename, Qnil); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1776 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1777 /* luckily, this returns the short version of each element in the path. */ |
100045
3ec2cc2d35c1
* w32proc.c: Include "coding.h".
Juanma Barranquero <lekktu@gmail.com>
parents:
96893
diff
changeset
|
1778 if (GetShortPathName (SDATA (ENCODE_FILE (filename)), shortname, MAX_PATH) == 0) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1779 return Qnil; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1780 |
108888
c2ac5cece5ea
Turn `directory-sep-char' into a noop.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
1781 dostounix_filename (shortname); |
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 return build_string (shortname); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1784 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1785 |
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 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
|
1788 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
|
1789 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
|
1790 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
|
1791 All path elements in FILENAME are converted to their long names. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109160
diff
changeset
|
1792 (Lisp_Object filename) |
19712
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 char longname[ MAX_PATH ]; |
96893
532dd6819465
(Fw32_long_file_name): Don't append dir separator to bare drive.
Jason Rumney <jasonr@gnu.org>
parents:
96376
diff
changeset
|
1795 int drive_only = 0; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1796 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
39812
diff
changeset
|
1797 CHECK_STRING (filename); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1798 |
96893
532dd6819465
(Fw32_long_file_name): Don't append dir separator to bare drive.
Jason Rumney <jasonr@gnu.org>
parents:
96376
diff
changeset
|
1799 if (SBYTES (filename) == 2 |
532dd6819465
(Fw32_long_file_name): Don't append dir separator to bare drive.
Jason Rumney <jasonr@gnu.org>
parents:
96376
diff
changeset
|
1800 && *(SDATA (filename) + 1) == ':') |
532dd6819465
(Fw32_long_file_name): Don't append dir separator to bare drive.
Jason Rumney <jasonr@gnu.org>
parents:
96376
diff
changeset
|
1801 drive_only = 1; |
532dd6819465
(Fw32_long_file_name): Don't append dir separator to bare drive.
Jason Rumney <jasonr@gnu.org>
parents:
96376
diff
changeset
|
1802 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1803 /* first expand it. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1804 filename = Fexpand_file_name (filename, Qnil); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1805 |
100045
3ec2cc2d35c1
* w32proc.c: Include "coding.h".
Juanma Barranquero <lekktu@gmail.com>
parents:
96893
diff
changeset
|
1806 if (!w32_get_long_filename (SDATA (ENCODE_FILE (filename)), longname, MAX_PATH)) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1807 return Qnil; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1808 |
108888
c2ac5cece5ea
Turn `directory-sep-char' into a noop.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
1809 dostounix_filename (longname); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1810 |
96893
532dd6819465
(Fw32_long_file_name): Don't append dir separator to bare drive.
Jason Rumney <jasonr@gnu.org>
parents:
96376
diff
changeset
|
1811 /* If we were passed only a drive, make sure that a slash is not appended |
532dd6819465
(Fw32_long_file_name): Don't append dir separator to bare drive.
Jason Rumney <jasonr@gnu.org>
parents:
96376
diff
changeset
|
1812 for consistency with directories. Allow for drive mapping via SUBST |
532dd6819465
(Fw32_long_file_name): Don't append dir separator to bare drive.
Jason Rumney <jasonr@gnu.org>
parents:
96376
diff
changeset
|
1813 in case expand-file-name is ever changed to expand those. */ |
532dd6819465
(Fw32_long_file_name): Don't append dir separator to bare drive.
Jason Rumney <jasonr@gnu.org>
parents:
96376
diff
changeset
|
1814 if (drive_only && longname[1] == ':' && longname[2] == '/' && !longname[3]) |
532dd6819465
(Fw32_long_file_name): Don't append dir separator to bare drive.
Jason Rumney <jasonr@gnu.org>
parents:
96376
diff
changeset
|
1815 longname[2] = '\0'; |
532dd6819465
(Fw32_long_file_name): Don't append dir separator to bare drive.
Jason Rumney <jasonr@gnu.org>
parents:
96376
diff
changeset
|
1816 |
100045
3ec2cc2d35c1
* w32proc.c: Include "coding.h".
Juanma Barranquero <lekktu@gmail.com>
parents:
96893
diff
changeset
|
1817 return DECODE_FILE (build_string (longname)); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1818 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1819 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1820 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
|
1821 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
|
1822 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
|
1823 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
|
1824 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
|
1825 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
|
1826 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
|
1827 |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1828 If successful, the return value is t, otherwise nil. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109160
diff
changeset
|
1829 (Lisp_Object process, Lisp_Object priority) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1830 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1831 HANDLE proc_handle = GetCurrentProcess (); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1832 DWORD priority_class = NORMAL_PRIORITY_CLASS; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1833 Lisp_Object result = Qnil; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1834 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
39812
diff
changeset
|
1835 CHECK_SYMBOL (priority); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1836 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1837 if (!NILP (process)) |
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 DWORD pid; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1840 child_process *cp; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1841 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
39812
diff
changeset
|
1842 CHECK_NUMBER (process); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1843 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1844 /* 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
|
1845 externally. This is necessary because real pids on Win95 are |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1846 negative. */ |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1847 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1848 pid = XINT (process); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1849 cp = find_child_pid (pid); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1850 if (cp != NULL) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1851 pid = cp->procinfo.dwProcessId; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1852 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1853 proc_handle = OpenProcess (PROCESS_SET_INFORMATION, FALSE, pid); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1854 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1855 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1856 if (EQ (priority, Qhigh)) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1857 priority_class = HIGH_PRIORITY_CLASS; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1858 else if (EQ (priority, Qlow)) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1859 priority_class = IDLE_PRIORITY_CLASS; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1860 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1861 if (proc_handle != NULL) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1862 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1863 if (SetPriorityClass (proc_handle, priority_class)) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1864 result = Qt; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1865 if (!NILP (process)) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1866 CloseHandle (proc_handle); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1867 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1868 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1869 return result; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1870 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1871 |
73091
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1872 #ifdef HAVE_LANGINFO_CODESET |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1873 /* Emulation of nl_langinfo. Used in fns.c:Flocale_info. */ |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
1874 char * |
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
1875 nl_langinfo (nl_item item) |
73091
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1876 { |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1877 /* Conversion of Posix item numbers to their Windows equivalents. */ |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1878 static const LCTYPE w32item[] = { |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1879 LOCALE_IDEFAULTANSICODEPAGE, |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1880 LOCALE_SDAYNAME1, LOCALE_SDAYNAME2, LOCALE_SDAYNAME3, |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1881 LOCALE_SDAYNAME4, LOCALE_SDAYNAME5, LOCALE_SDAYNAME6, LOCALE_SDAYNAME7, |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1882 LOCALE_SMONTHNAME1, LOCALE_SMONTHNAME2, LOCALE_SMONTHNAME3, |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1883 LOCALE_SMONTHNAME4, LOCALE_SMONTHNAME5, LOCALE_SMONTHNAME6, |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1884 LOCALE_SMONTHNAME7, LOCALE_SMONTHNAME8, LOCALE_SMONTHNAME9, |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1885 LOCALE_SMONTHNAME10, LOCALE_SMONTHNAME11, LOCALE_SMONTHNAME12 |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1886 }; |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1887 |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1888 static char *nl_langinfo_buf = NULL; |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1889 static int nl_langinfo_len = 0; |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1890 |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1891 if (nl_langinfo_len <= 0) |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1892 nl_langinfo_buf = xmalloc (nl_langinfo_len = 1); |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1893 |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1894 if (item < 0 || item >= _NL_NUM) |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1895 nl_langinfo_buf[0] = 0; |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1896 else |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1897 { |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1898 LCID cloc = GetThreadLocale (); |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1899 int need_len = GetLocaleInfo (cloc, w32item[item] | LOCALE_USE_CP_ACP, |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1900 NULL, 0); |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1901 |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1902 if (need_len <= 0) |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1903 nl_langinfo_buf[0] = 0; |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1904 else |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1905 { |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1906 if (item == CODESET) |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1907 { |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1908 need_len += 2; /* for the "cp" prefix */ |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1909 if (need_len < 8) /* for the case we call GetACP */ |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1910 need_len = 8; |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1911 } |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1912 if (nl_langinfo_len <= need_len) |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1913 nl_langinfo_buf = xrealloc (nl_langinfo_buf, |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1914 nl_langinfo_len = need_len); |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1915 if (!GetLocaleInfo (cloc, w32item[item] | LOCALE_USE_CP_ACP, |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1916 nl_langinfo_buf, nl_langinfo_len)) |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1917 nl_langinfo_buf[0] = 0; |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1918 else if (item == CODESET) |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1919 { |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1920 if (strcmp (nl_langinfo_buf, "0") == 0 /* CP_ACP */ |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1921 || strcmp (nl_langinfo_buf, "1") == 0) /* CP_OEMCP */ |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1922 sprintf (nl_langinfo_buf, "cp%u", GetACP ()); |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1923 else |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1924 { |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1925 memmove (nl_langinfo_buf + 2, nl_langinfo_buf, |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1926 strlen (nl_langinfo_buf) + 1); |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1927 nl_langinfo_buf[0] = 'c'; |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1928 nl_langinfo_buf[1] = 'p'; |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1929 } |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1930 } |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1931 } |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1932 } |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1933 return nl_langinfo_buf; |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1934 } |
fd4e9d08fa35
(nl_langinfo): New function.
Eli Zaretskii <eliz@gnu.org>
parents:
71901
diff
changeset
|
1935 #endif /* HAVE_LANGINFO_CODESET */ |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1936 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1937 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
|
1938 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
|
1939 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
|
1940 By default, return a three letter locale code which encodes the default |
100062
d4660dbaa550
* w32proc.c (Fw32_get_locale_info): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
100045
diff
changeset
|
1941 language as the first two characters, and the country or regional variant |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1942 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
|
1943 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
|
1944 |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1945 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
|
1946 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
|
1947 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
|
1948 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
|
1949 |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1950 If LCID (a 16-bit number) is not a valid locale, the result is nil. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109160
diff
changeset
|
1951 (Lisp_Object lcid, Lisp_Object longform) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1952 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1953 int got_abbrev; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1954 int got_full; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1955 char abbrev_name[32] = { 0 }; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1956 char full_name[256] = { 0 }; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1957 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
39812
diff
changeset
|
1958 CHECK_NUMBER (lcid); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1959 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1960 if (!IsValidLocale (XINT (lcid), LCID_SUPPORTED)) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1961 return Qnil; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1962 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1963 if (NILP (longform)) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1964 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1965 got_abbrev = GetLocaleInfo (XINT (lcid), |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1966 LOCALE_SABBREVLANGNAME | LOCALE_USE_CP_ACP, |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1967 abbrev_name, sizeof (abbrev_name)); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1968 if (got_abbrev) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1969 return build_string (abbrev_name); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1970 } |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1971 else if (EQ (longform, Qt)) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1972 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1973 got_full = GetLocaleInfo (XINT (lcid), |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1974 LOCALE_SLANGUAGE | LOCALE_USE_CP_ACP, |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1975 full_name, sizeof (full_name)); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1976 if (got_full) |
100351
d23b1588c7c1
Move decoding of locale info from Lisp to C.
Juanma Barranquero <lekktu@gmail.com>
parents:
100062
diff
changeset
|
1977 return DECODE_SYSTEM (build_string (full_name)); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1978 } |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1979 else if (NUMBERP (longform)) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1980 { |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1981 got_full = GetLocaleInfo (XINT (lcid), |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1982 XINT (longform), |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1983 full_name, sizeof (full_name)); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1984 if (got_full) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
1985 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
|
1986 } |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1987 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1988 return Qnil; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1989 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1990 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1991 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
1992 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
|
1993 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
|
1994 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
|
1995 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
|
1996 human-readable form. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109160
diff
changeset
|
1997 (void) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1998 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
1999 return make_number (GetThreadLocale ()); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2000 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2001 |
110975
e0ac9a58795e
src/w32*.c: Make functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110431
diff
changeset
|
2002 static DWORD |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
2003 int_from_hex (char * s) |
21613
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2004 { |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2005 DWORD val = 0; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2006 static char hex[] = "0123456789abcdefABCDEF"; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2007 char * p; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2008 |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
2009 while (*s && (p = strchr (hex, *s)) != NULL) |
21613
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2010 { |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2011 unsigned digit = p - hex; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2012 if (digit > 15) |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2013 digit -= 6; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2014 val = val * 16 + digit; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2015 s++; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2016 } |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2017 return val; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2018 } |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2019 |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2020 /* 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
|
2021 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
|
2022 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
|
2023 |
110975
e0ac9a58795e
src/w32*.c: Make functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110431
diff
changeset
|
2024 static BOOL CALLBACK |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
2025 enum_locale_fn (LPTSTR localeNum) |
21613
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2026 { |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2027 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
|
2028 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
|
2029 return TRUE; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2030 } |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2031 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2032 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
|
2033 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
|
2034 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
|
2035 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
|
2036 human-readable form. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109160
diff
changeset
|
2037 (void) |
21613
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2038 { |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2039 Vw32_valid_locale_ids = Qnil; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2040 |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2041 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
|
2042 |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2043 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
|
2044 return Vw32_valid_locale_ids; |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2045 } |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2046 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2047 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2048 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
|
2049 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
|
2050 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
|
2051 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
|
2052 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
|
2053 human-readable form. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109160
diff
changeset
|
2054 (Lisp_Object userp) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2055 { |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2056 if (NILP (userp)) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2057 return make_number (GetSystemDefaultLCID ()); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2058 return make_number (GetUserDefaultLCID ()); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2059 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2060 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
2061 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2062 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
|
2063 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
|
2064 If successful, the new locale id is returned, otherwise nil. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109160
diff
changeset
|
2065 (Lisp_Object lcid) |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2066 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
39812
diff
changeset
|
2067 CHECK_NUMBER (lcid); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2068 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2069 if (!IsValidLocale (XINT (lcid), LCID_SUPPORTED)) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2070 return Qnil; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2071 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2072 if (!SetThreadLocale (XINT (lcid))) |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2073 return Qnil; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2074 |
21613
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2075 /* 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
|
2076 if (dwWindowsThreadId) |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2077 /* Reply is not needed. */ |
fe4f5bfae371
(w32_executable_type): Properly cast dos_header when
Geoff Voelker <voelker@cs.washington.edu>
parents:
21452
diff
changeset
|
2078 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
|
2079 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2080 return make_number (GetThreadLocale ()); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2081 } |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2082 |
23678
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 /* 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
|
2085 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
|
2086 Lisp_Object Vw32_valid_codepages; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2087 |
110975
e0ac9a58795e
src/w32*.c: Make functions static.
Juanma Barranquero <lekktu@gmail.com>
parents:
110431
diff
changeset
|
2088 static BOOL CALLBACK |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
2089 enum_codepage_fn (LPTSTR codepageNum) |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2090 { |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2091 DWORD id = atoi (codepageNum); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2092 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
|
2093 return TRUE; |
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 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2096 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
|
2097 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
|
2098 doc: /* Return list of all valid Windows codepages. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109160
diff
changeset
|
2099 (void) |
23678
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 Vw32_valid_codepages = Qnil; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2102 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2103 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
|
2104 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2105 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
|
2106 return Vw32_valid_codepages; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2107 } |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2108 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2109 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2110 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
|
2111 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
|
2112 doc: /* Return current Windows codepage for console input. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109160
diff
changeset
|
2113 (void) |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2114 { |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2115 return make_number (GetConsoleCP ()); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2116 } |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2117 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
2118 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2119 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
|
2120 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
|
2121 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
|
2122 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
|
2123 If successful, the new CP is returned, otherwise nil. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109160
diff
changeset
|
2124 (Lisp_Object cp) |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2125 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
39812
diff
changeset
|
2126 CHECK_NUMBER (cp); |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2127 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2128 if (!IsValidCodePage (XINT (cp))) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2129 return Qnil; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2130 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2131 if (!SetConsoleCP (XINT (cp))) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2132 return Qnil; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2133 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2134 return make_number (GetConsoleCP ()); |
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 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2137 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2138 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
|
2139 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
|
2140 doc: /* Return current Windows codepage for console output. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109160
diff
changeset
|
2141 (void) |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2142 { |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2143 return make_number (GetConsoleOutputCP ()); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2144 } |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2145 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
2146 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2147 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
|
2148 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
|
2149 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
|
2150 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
|
2151 If successful, the new CP is returned, otherwise nil. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109160
diff
changeset
|
2152 (Lisp_Object cp) |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2153 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
39812
diff
changeset
|
2154 CHECK_NUMBER (cp); |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2155 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2156 if (!IsValidCodePage (XINT (cp))) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2157 return Qnil; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2158 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2159 if (!SetConsoleOutputCP (XINT (cp))) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2160 return Qnil; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2161 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2162 return make_number (GetConsoleOutputCP ()); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2163 } |
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 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2166 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
|
2167 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
|
2168 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
|
2169 Returns nil if the codepage is not valid. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109160
diff
changeset
|
2170 (Lisp_Object cp) |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2171 { |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2172 CHARSETINFO info; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2173 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
39812
diff
changeset
|
2174 CHECK_NUMBER (cp); |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2175 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2176 if (!IsValidCodePage (XINT (cp))) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2177 return Qnil; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2178 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2179 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
|
2180 return make_number (info.ciCharset); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2181 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2182 return Qnil; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2183 } |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2184 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2185 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2186 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
|
2187 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
|
2188 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
|
2189 The return value is a list of pairs of language id and layout id. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109160
diff
changeset
|
2190 (void) |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2191 { |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2192 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
|
2193 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
|
2194 Lisp_Object obj = Qnil; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2195 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2196 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
|
2197 { |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2198 while (--num_layouts >= 0) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2199 { |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2200 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
|
2201 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2202 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
|
2203 make_number ((kl >> 16) & 0xffff)), |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2204 obj); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2205 } |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2206 } |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2207 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2208 return obj; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2209 } |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2210 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2211 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2212 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
|
2213 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
|
2214 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
|
2215 The return value is the cons of the language id and the layout id. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109160
diff
changeset
|
2216 (void) |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2217 { |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2218 DWORD kl = (DWORD) GetKeyboardLayout (dwWindowsThreadId); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2219 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2220 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
|
2221 make_number ((kl >> 16) & 0xffff)); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2222 } |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2223 |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
2224 |
40962
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2225 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
|
2226 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
|
2227 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
|
2228 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
|
2229 If successful, the new layout id is returned, otherwise nil. */) |
109179
8cfee7d2955f
Convert DEFUNs to standard C.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
109160
diff
changeset
|
2230 (Lisp_Object layout) |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2231 { |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2232 DWORD kl; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2233 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
39812
diff
changeset
|
2234 CHECK_CONS (layout); |
40752
8b5deb3bca03
(Fw32_set_keyboard_layout): Use CHECK_NUMBER_CAR and
Andrew Innes <andrewi@gnu.org>
parents:
40656
diff
changeset
|
2235 CHECK_NUMBER_CAR (layout); |
8b5deb3bca03
(Fw32_set_keyboard_layout): Use CHECK_NUMBER_CAR and
Andrew Innes <andrewi@gnu.org>
parents:
40656
diff
changeset
|
2236 CHECK_NUMBER_CDR (layout); |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2237 |
25646
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
24915
diff
changeset
|
2238 kl = (XINT (XCAR (layout)) & 0xffff) |
9154af188477
Use XCAR and XCDR instead of explicit member references.
Ken Raeburn <raeburn@raeburn.org>
parents:
24915
diff
changeset
|
2239 | (XINT (XCDR (layout)) << 16); |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2240 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2241 /* Synchronize layout with input thread. */ |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2242 if (dwWindowsThreadId) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2243 { |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2244 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
|
2245 (WPARAM) kl, 0)) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2246 { |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2247 MSG msg; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2248 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
|
2249 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2250 if (msg.wParam == 0) |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2251 return Qnil; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2252 } |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2253 } |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2254 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
|
2255 return Qnil; |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2256 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2257 return Fw32_get_keyboard_layout (); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2258 } |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2259 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2260 |
110994
734b2470f93c
src/w32*.c: Whitespace fixes and typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
106815
diff
changeset
|
2261 void |
109152
e27859da5624
src/w32*.c: Convert function definitions to standard C.
Juanma Barranquero <lekktu@gmail.com>
parents:
108888
diff
changeset
|
2262 syms_of_ntproc (void) |
15201
43551ec4b69d
(Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15145
diff
changeset
|
2263 { |
90921
47c076d206e6
(syms_of_ntproc): Use DEFSYM macro.
Jason Rumney <jasonr@gnu.org>
parents:
90737
diff
changeset
|
2264 DEFSYM (Qhigh, "high"); |
47c076d206e6
(syms_of_ntproc): Use DEFSYM macro.
Jason Rumney <jasonr@gnu.org>
parents:
90737
diff
changeset
|
2265 DEFSYM (Qlow, "low"); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2266 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
2267 defsubr (&Sw32_has_winsock); |
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
2268 defsubr (&Sw32_unload_winsock); |
110431
9fe8167bbd9b
Don't make W32 code conditional on HAVE_SOCKETS, it's always defined.
Juanma Barranquero <lekktu@gmail.com>
parents:
109179
diff
changeset
|
2269 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2270 defsubr (&Sw32_short_file_name); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2271 defsubr (&Sw32_long_file_name); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2272 defsubr (&Sw32_set_process_priority); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2273 defsubr (&Sw32_get_locale_info); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2274 defsubr (&Sw32_get_current_locale_id); |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2275 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
|
2276 defsubr (&Sw32_get_valid_locale_ids); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2277 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
|
2278 |
23678
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2279 defsubr (&Sw32_get_console_codepage); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2280 defsubr (&Sw32_set_console_codepage); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2281 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
|
2282 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
|
2283 defsubr (&Sw32_get_valid_codepages); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2284 defsubr (&Sw32_get_codepage_charset); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2285 |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2286 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
|
2287 defsubr (&Sw32_get_keyboard_layout); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2288 defsubr (&Sw32_set_keyboard_layout); |
b2480e274f42
(sys_kill): Set extended key flag when faking
Geoff Voelker <voelker@cs.washington.edu>
parents:
22298
diff
changeset
|
2289 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
2290 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
|
2291 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
|
2292 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
|
2293 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
|
2294 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
|
2295 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
|
2296 |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2297 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
|
2298 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
|
2299 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
|
2300 Vw32_quote_process_args = Qt; |
15247
874a66251747
(Vwin32_pipe_read_delay): New var.
Karl Heuer <kwzh@gnu.org>
parents:
15201
diff
changeset
|
2301 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
2302 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
|
2303 &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
|
2304 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
|
2305 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
|
2306 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
|
2307 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
|
2308 |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2309 DEFVAR_LISP ("w32-start-process-share-console", |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2310 &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
|
2311 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
|
2312 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
|
2313 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
|
2314 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
|
2315 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
|
2316 otherwise respond to interrupts from Emacs. */); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2317 Vw32_start_process_share_console = Qnil; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2318 |
23949
9f8417cca07b
(Vw32_start_process_inherit_error_mode): New variable.
Andrew Innes <andrewi@gnu.org>
parents:
23678
diff
changeset
|
2319 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
|
2320 &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
|
2321 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
|
2322 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
|
2323 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
|
2324 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
|
2325 |
55642
d69e0fb91340
* w32proc.c (w32_pipe_read_delay): Rename from Vw32_pipe_read_delay
Jason Rumney <jasonr@gnu.org>
parents:
52401
diff
changeset
|
2326 DEFVAR_INT ("w32-pipe-read-delay", &w32_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
|
2327 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
|
2328 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
|
2329 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
|
2330 |
f66d09d1bb2f
Change doc-string comments to `new style'. [w/`doc:' keyword]. Doc fixes.
Jason Rumney <jasonr@gnu.org>
parents:
40752
diff
changeset
|
2331 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
|
2332 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
|
2333 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
|
2334 process temporarily). A value of zero disables waiting entirely. */); |
55642
d69e0fb91340
* w32proc.c (w32_pipe_read_delay): Rename from Vw32_pipe_read_delay
Jason Rumney <jasonr@gnu.org>
parents:
52401
diff
changeset
|
2335 w32_pipe_read_delay = 50; |
15325
5c8e4ef3137c
(Vwin32_downcase_file_names): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15247
diff
changeset
|
2336 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
2337 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
|
2338 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
|
2339 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
|
2340 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
|
2341 so you probably don't want to set to non-nil if you use case-sensitive |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46750
diff
changeset
|
2342 filesystems via ange-ftp. */); |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16000
diff
changeset
|
2343 Vw32_downcase_file_names = Qnil; |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2344 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2345 #if 0 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2346 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
|
2347 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
|
2348 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
|
2349 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
|
2350 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
|
2351 the truename of a file can be slow. */); |
19712
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2352 Vw32_generate_fake_inodes = Qnil; |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2353 #endif |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2354 |
9a6e50f6b471
Include w32heap.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
2355 DEFVAR_LISP ("w32-get-true-file-attributes", &Vw32_get_true_file_attributes, |
94839
f82e9e80393e
(syms_of_ntproc) <w32-get-true-file-attributes>: Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
94293
diff
changeset
|
2356 doc: /* Non-nil means determine accurate file attributes in `file-attributes'. |
f82e9e80393e
(syms_of_ntproc) <w32-get-true-file-attributes>: Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
94293
diff
changeset
|
2357 This option controls whether to issue additional system calls to determine |
103813
c7da7466b614
(syms_of_ntproc) <w32-get-true-file-attributes>: Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
100951
diff
changeset
|
2358 accurate link counts, file type, and ownership information. It is more |
94839
f82e9e80393e
(syms_of_ntproc) <w32-get-true-file-attributes>: Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
94293
diff
changeset
|
2359 useful for files on NTFS volumes, where hard links and file security are |
103813
c7da7466b614
(syms_of_ntproc) <w32-get-true-file-attributes>: Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
100951
diff
changeset
|
2360 supported, than on volumes of the FAT family. |
94839
f82e9e80393e
(syms_of_ntproc) <w32-get-true-file-attributes>: Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
94293
diff
changeset
|
2361 |
f82e9e80393e
(syms_of_ntproc) <w32-get-true-file-attributes>: Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
94293
diff
changeset
|
2362 Without these system calls, link count will always be reported as 1 and file |
f82e9e80393e
(syms_of_ntproc) <w32-get-true-file-attributes>: Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
94293
diff
changeset
|
2363 ownership will be attributed to the current user. |
f82e9e80393e
(syms_of_ntproc) <w32-get-true-file-attributes>: Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
94293
diff
changeset
|
2364 The default value `local' means only issue these system calls for files |
f82e9e80393e
(syms_of_ntproc) <w32-get-true-file-attributes>: Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
94293
diff
changeset
|
2365 on local fixed drives. A value of nil means never issue them. |
f82e9e80393e
(syms_of_ntproc) <w32-get-true-file-attributes>: Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
94293
diff
changeset
|
2366 Any other non-nil value means do this even on remote and removable drives |
f82e9e80393e
(syms_of_ntproc) <w32-get-true-file-attributes>: Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents:
94293
diff
changeset
|
2367 where the performance impact may be noticeable even on modern hardware. */); |
80485
f1f27e9c15d7
(syms_of_ntproc): Change Vw32_get_true_file attributes
Jason Rumney <jasonr@gnu.org>
parents:
79759
diff
changeset
|
2368 Vw32_get_true_file_attributes = Qlocal; |
64363
71c7519df9b7
(syms_of_ntproc): staticpro Qhigh, Qlow,
Eli Zaretskii <eliz@gnu.org>
parents:
64084
diff
changeset
|
2369 |
71c7519df9b7
(syms_of_ntproc): staticpro Qhigh, Qlow,
Eli Zaretskii <eliz@gnu.org>
parents:
64084
diff
changeset
|
2370 staticpro (&Vw32_valid_locale_ids); |
71c7519df9b7
(syms_of_ntproc): staticpro Qhigh, Qlow,
Eli Zaretskii <eliz@gnu.org>
parents:
64084
diff
changeset
|
2371 staticpro (&Vw32_valid_codepages); |
15201
43551ec4b69d
(Vwin32_quote_process_args): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
15145
diff
changeset
|
2372 } |
15145
86a1f426871e
Include config.h after CRT headers. Include fcntl.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
2373 /* end of ntproc.c */ |
52401 | 2374 |
2375 /* arch-tag: 23d3a34c-06d2-48a1-833b-ac7609aa5250 | |
2376 (do not change this comment) */ |