annotate src/w32.h @ 15145:86a1f426871e

Include config.h after CRT headers. Include fcntl.h. (child_process, MAX_CHILDREN, CHILD_ACTIVE): Moved to nt.h. (DebugPrint): New macro. (new_child): Create input event structures for child processes. (delete_child): New function. (reader_thread): Return nonzero upon failure. Use _sys_read_ahead. (create_child): Add child_process and parent PID arguments. Don't create input event or thread structures here. Fixup Win95 negative process IDs. (register_child): Don't set consumed event; instead, set thread status so that select will release it. (remove_child): Renamed to reap_process. Only free resources of synchronous children. (win32_wait): Renamed to sys_wait. Sanity check to make sure handle to subprocess exists. Don't reclaim thread resources here. (win32_spawnve): Renamed to sys_spawnve. Check for proper wait mode first thing. Convert command name to DOS format. Quote whitespace and quotes in arguments to subprocess. Use alloca instead of malloc. If max subprocesses, return EAGAIN in hopes of another completing. (sys_select): Add support for socket input. Remove dead code. Check input from children fairly. (sys_select) [HAVE_TIMEVAL]: Remove conditional check and code. (win32_kill_process): Renamed to sys_kill. Use OpenProcess to terminate process. (prepate_standard_handles, reset_standard_handles): Moved here from nt.c.
author Geoff Voelker <voelker@cs.washington.edu>
date Fri, 03 May 1996 18:35:50 +0000
parents 6879c02a290c
children e9d9c86ed820
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15142
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
1 #ifndef _NT_H_
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
2 #define _NT_H_
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
3
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4 /* Support routines for the NT version of Emacs.
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 Copyright (C) 1994 Free Software Foundation, Inc.
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 This file is part of GNU Emacs.
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 GNU Emacs is free software; you can redistribute it and/or modify
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 it under the terms of the GNU General Public License as published by
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 the Free Software Foundation; either version 2, or (at your option)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 any later version.
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 GNU Emacs is distributed in the hope that it will be useful,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 GNU General Public License for more details.
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 along with GNU Emacs; see the file COPYING. If not, write to
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 13426
diff changeset
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 13426
diff changeset
22 Boston, MA 02111-1307, USA. */
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
15142
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
24 /* #define FULL_DEBUG */
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
25 #define EMACSDEBUG
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
26
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
27 #ifdef EMACSDEBUG
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
28 #define DebPrint(stuff) _DebPrint stuff
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
29 #else
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
30 #define DebPrint(stuff)
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
31 #endif
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
32
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 /* File descriptor set emulation. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34
15142
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
35 /* MSVC runtime library has limit of 64 descriptors by default */
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
36 #define FD_SETSIZE 64
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
37 typedef struct {
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
38 unsigned int bits[FD_SETSIZE / 32];
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
39 } fd_set;
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
40
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
41 /* standard access macros */
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
42 #define FD_SET(n, p) \
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
43 do { \
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
44 if ((n) < FD_SETSIZE) { \
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
45 (p)->bits[(n)/32] |= (1 << (n)%32); \
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
46 } \
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
47 } while (0)
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
48 #define FD_CLR(n, p) \
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
49 do { \
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
50 if ((n) < FD_SETSIZE) { \
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
51 (p)->bits[(n)/32] &= ~(1 << (n)%32); \
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
52 } \
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
53 } while (0)
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
54 #define FD_ISSET(n, p) ((n) < FD_SETSIZE ? ((p)->bits[(n)/32] & (1 << (n)%32)) : 0)
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
55 #define FD_ZERO(p) memset((p), 0, sizeof(fd_set))
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
56
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 #define SELECT_TYPE fd_set
15142
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
58
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
59 /* ------------------------------------------------------------------------- */
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
60
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
61 /* child_process.status values */
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
62 enum {
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
63 STATUS_READ_ERROR = -1,
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
64 STATUS_READ_READY,
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
65 STATUS_READ_IN_PROGRESS,
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
66 STATUS_READ_FAILED,
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
67 STATUS_READ_SUCCEEDED,
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
68 STATUS_READ_ACKNOWLEDGED
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
69 };
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
70
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
71 /* This structure is used for both pipes and sockets; for
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
72 a socket, the process handle in pi is NULL. */
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
73 typedef struct _child_process
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
74 {
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
75 int fd;
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
76 int pid;
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
77 HANDLE char_avail;
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
78 HANDLE char_consumed;
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
79 HANDLE thrd;
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
80 PROCESS_INFORMATION procinfo;
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
81 volatile int status;
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
82 char chr;
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
83 } child_process;
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84
15142
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
85 #define MAXDESC FD_SETSIZE
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
86 #define MAX_CHILDREN MAXDESC/2
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
87 #define CHILD_ACTIVE(cp) ((cp)->char_avail != NULL)
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
88
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
89 /* parallel array of private info on file handles */
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
90 typedef struct
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
91 {
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
92 unsigned flags;
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
93 HANDLE hnd;
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
94 child_process * cp;
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
95 } filedesc;
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
96
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
97 extern filedesc fd_info [ MAXDESC ];
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
98
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
99 /* fd_info flag definitions */
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
100 #define FILE_READ 0x0001
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
101 #define FILE_WRITE 0x0002
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
102 #define FILE_BINARY 0x0010
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
103 #define FILE_PIPE 0x0100
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
104 #define FILE_SOCKET 0x0200
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
105
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
106 extern child_process * new_child (void);
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
107 extern void delete_child (child_process *cp);
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
108
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
109 /* ------------------------------------------------------------------------- */
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
110
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 /* Prepare our standard handles for proper inheritance by child processes. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 extern void prepare_standard_handles (int in, int out,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 int err, HANDLE handles[4]);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 /* Reset our standard handles to their original state. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 extern void reset_standard_handles (int in, int out,
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 int err, HANDLE handles[4]);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119
13426
8074deaef2f4 (nt_get_resource): Prototype defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 9803
diff changeset
120 /* Return the string resource associated with KEY of type TYPE. */
15142
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
121 extern LPBYTE nt_get_resource (char * key, LPDWORD type);
13426
8074deaef2f4 (nt_get_resource): Prototype defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 9803
diff changeset
122
15142
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
123 extern void init_ntproc ();
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
124 extern void term_ntproc ();
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
125
6879c02a290c Check to see if already included.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
126 #endif /* _NT_H_ */