428
|
1 /*
|
|
2 Copyright (C) 1995 Free Software Foundation, Inc.
|
853
|
3 Copyright (C) 2000, 2002 Ben Wing.
|
428
|
4
|
|
5 This file is part of XEmacs.
|
|
6
|
|
7 XEmacs is free software; you can redistribute it and/or modify it
|
|
8 under the terms of the GNU General Public License as published by the
|
|
9 Free Software Foundation; either version 2, or (at your option) any
|
|
10 later version.
|
|
11
|
|
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
15 for more details.
|
|
16
|
|
17 You should have received a copy of the GNU General Public License
|
|
18 along with XEmacs; see the file COPYING. If not, write to
|
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
20 Boston, MA 02111-1307, USA. */
|
|
21
|
|
22 /* Synched up with: Not really in FSF. */
|
|
23
|
440
|
24 #ifndef INCLUDED_sysproc_h_
|
|
25 #define INCLUDED_sysproc_h_
|
|
26
|
428
|
27 #include "systime.h" /* necessary for sys/resource.h; also gets the
|
|
28 FD_* defines on some systems. */
|
442
|
29 #ifndef WIN32_NATIVE
|
428
|
30 #include <sys/resource.h>
|
|
31 #endif
|
|
32
|
|
33 #if !defined (NO_SUBPROCESSES)
|
|
34
|
771
|
35 #ifdef MINGW
|
|
36 #include <../mingw/process.h>
|
|
37 #elif defined (CYGWIN)
|
|
38 #include <../include/process.h>
|
|
39 #elif defined (WIN32_NATIVE)
|
|
40 /* <process.h> should not conflict with "process.h", as per ANSI definition.
|
|
41 This is not true with visual c though. The trick below works with
|
|
42 VC4.2b, 5.0 and 6.0. It assumes that VC is installed in a kind of
|
|
43 standard way, so include path ends with /include.
|
|
44 */
|
|
45 #include <../include/process.h>
|
|
46 #endif
|
|
47
|
428
|
48 #ifdef HAVE_SOCKETS /* TCP connection support, if kernel can do it */
|
|
49 # include <sys/types.h> /* AJK */
|
442
|
50 # ifndef WIN32_NATIVE
|
|
51 # include <sys/socket.h>
|
|
52 # include <netdb.h>
|
|
53 # include <netinet/in.h>
|
|
54 # include <arpa/inet.h>
|
|
55 # endif
|
|
56 # ifdef NEED_NET_ERRNO_H
|
|
57 # include <net/errno.h>
|
|
58 # endif /* NEED_NET_ERRNO_H */
|
428
|
59 #elif defined (SKTPAIR)
|
|
60 # include <sys/socket.h>
|
|
61 #endif /* HAVE_SOCKETS */
|
|
62
|
442
|
63 #ifdef WIN32_NATIVE
|
|
64 /* Note: winsock.h already included in systime.h above */
|
|
65 /* map winsock error codes to standard names */
|
|
66 #define EWOULDBLOCK WSAEWOULDBLOCK
|
|
67 #define EINPROGRESS WSAEINPROGRESS
|
|
68 #define EALREADY WSAEALREADY
|
|
69 #define ENOTSOCK WSAENOTSOCK
|
|
70 #define EDESTADDRREQ WSAEDESTADDRREQ
|
|
71 #define EMSGSIZE WSAEMSGSIZE
|
|
72 #define EPROTOTYPE WSAEPROTOTYPE
|
|
73 #define ENOPROTOOPT WSAENOPROTOOPT
|
|
74 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
|
|
75 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
|
|
76 #define EOPNOTSUPP WSAEOPNOTSUPP
|
|
77 #define EPFNOSUPPORT WSAEPFNOSUPPORT
|
|
78 #define EAFNOSUPPORT WSAEAFNOSUPPORT
|
|
79 #define EADDRINUSE WSAEADDRINUSE
|
|
80 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
|
|
81 #define ENETDOWN WSAENETDOWN
|
|
82 #define ENETUNREACH WSAENETUNREACH
|
|
83 #define ENETRESET WSAENETRESET
|
|
84 #define ECONNABORTED WSAECONNABORTED
|
|
85 #define ECONNRESET WSAECONNRESET
|
|
86 #define ENOBUFS WSAENOBUFS
|
|
87 #define EISCONN WSAEISCONN
|
|
88 #define ENOTCONN WSAENOTCONN
|
|
89 #define ESHUTDOWN WSAESHUTDOWN
|
|
90 #define ETOOMANYREFS WSAETOOMANYREFS
|
|
91 #define ETIMEDOUT WSAETIMEDOUT
|
|
92 #define ECONNREFUSED WSAECONNREFUSED
|
|
93 #define ELOOP WSAELOOP
|
|
94 /* #define ENAMETOOLONG WSAENAMETOOLONG */
|
|
95 #define EHOSTDOWN WSAEHOSTDOWN
|
|
96 #define EHOSTUNREACH WSAEHOSTUNREACH
|
|
97 /* #define ENOTEMPTY WSAENOTEMPTY */
|
|
98 #define EPROCLIM WSAEPROCLIM
|
|
99 #define EUSERS WSAEUSERS
|
|
100 #define EDQUOT WSAEDQUOT
|
|
101 #define ESTALE WSAESTALE
|
|
102 #define EREMOTE WSAEREMOTE
|
|
103 #endif /* WIN32_NATIVE */
|
|
104
|
3025
|
105 /* On some systems, e.g. DGUX, inet_addr returns a `struct in_addr'. */
|
428
|
106 #ifdef HAVE_BROKEN_INET_ADDR
|
|
107 # define IN_ADDR struct in_addr
|
|
108 # define NUMERIC_ADDR_ERROR (numeric_addr.s_addr == -1)
|
|
109 #else
|
|
110 # if (LONGBITS > 32)
|
|
111 # define IN_ADDR unsigned int
|
|
112 # else
|
|
113 # define IN_ADDR unsigned long
|
|
114 # endif
|
|
115 # define NUMERIC_ADDR_ERROR (numeric_addr == (IN_ADDR) -1)
|
|
116 #endif
|
|
117
|
|
118 /* Define first descriptor number available for subprocesses. */
|
|
119 #define FIRST_PROC_DESC 3
|
|
120
|
|
121 #ifdef IRIS
|
|
122 # include <sys/sysmacros.h> /* for "minor" */
|
|
123 #endif /* not IRIS */
|
|
124
|
|
125 #endif /* !NO_SUBPROCESSES */
|
|
126
|
|
127 #ifdef AIX
|
|
128 #include <sys/select.h>
|
|
129 #endif
|
|
130
|
444
|
131 #ifdef HAVE_STROPTS_H
|
|
132 #include <stropts.h> /* isastream(), I_PUSH */
|
442
|
133 #endif
|
|
134
|
444
|
135 #ifdef HAVE_STRTIO_H
|
|
136 #include <strtio.h> /* TIOCSIGNAL */
|
442
|
137 #endif
|
|
138
|
|
139 #ifdef HAVE_PTY_H
|
|
140 #include <pty.h> /* openpty() on Tru64, Linux */
|
|
141 #endif
|
|
142
|
|
143 #ifdef HAVE_LIBUTIL_H
|
458
|
144 #include <libutil.h> /* openpty() on FreeBSD */
|
|
145 #endif
|
|
146
|
|
147 #ifdef HAVE_UTIL_H
|
|
148 #include <util.h> /* openpty() on NetBSD */
|
442
|
149 #endif
|
|
150
|
2286
|
151 /* The FD_* macros expand to __extension__ forms on glibc-based systems. Uno
|
|
152 does not understand such forms, so let's help it out. */
|
|
153 #ifdef UNO
|
|
154 #undef FD_SET
|
|
155 #undef FD_CLR
|
|
156 #undef FD_ISSET
|
|
157 #undef FD_ZERO
|
|
158 #undef MAXDESC
|
|
159 #undef SELECT_TYPE
|
|
160 #endif /* UNO */
|
|
161
|
428
|
162 #ifdef FD_SET
|
|
163
|
|
164 /* We could get this from param.h, but better not to depend on finding that.
|
|
165 And better not to risk that it might define other symbols used in this
|
|
166 file. */
|
|
167 # ifdef FD_SETSIZE
|
|
168 # define MAXDESC FD_SETSIZE
|
|
169 # else
|
|
170 # define MAXDESC 64
|
|
171 # endif /* FD_SETSIZE */
|
|
172 # define SELECT_TYPE fd_set
|
|
173
|
|
174 #else /* no FD_SET */
|
|
175
|
|
176 # define MAXDESC 32
|
|
177 # define SELECT_TYPE int
|
|
178
|
|
179 /* Define the macros to access a single-int bitmap of descriptors. */
|
|
180 # define FD_SET(n, p) (*(p) |= (1 << (n)))
|
|
181 # define FD_CLR(n, p) (*(p) &= ~(1 << (n)))
|
|
182 # define FD_ISSET(n, p) (*(p) & (1 << (n)))
|
|
183 # define FD_ZERO(p) (*(p) = 0)
|
|
184
|
|
185 #endif /* no FD_SET */
|
|
186
|
|
187 int poll_fds_for_input (SELECT_TYPE mask);
|
867
|
188 int qxe_execve (const Ibyte *filename, Ibyte * const argv[],
|
|
189 Ibyte * const envp[]);
|
771
|
190 pid_t qxe_getpid (void);
|
428
|
191
|
853
|
192 /* #### I would really like to delete the remaining synchronous code entirely.
|
|
193 We are now using it only for *REALLY* old systems -- how many systems
|
|
194 nowadays
|
|
195
|
|
196 (a) lack job control, or
|
|
197 (b) lack mkdir() or rmdir()
|
|
198
|
|
199 ?????
|
|
200
|
|
201 --ben
|
|
202 */
|
|
203
|
859
|
204 #include "syssignal.h" /* needed for SIGTSTP */
|
854
|
205
|
853
|
206 #if !defined (WIN32_NATIVE) && ((!defined (SIGTSTP) && !defined (USG_JOBCTRL)) || !defined (HAVE_MKDIR) || !defined (HAVE_RMDIR))
|
|
207
|
|
208 #define NEED_SYNC_PROCESS_CODE
|
|
209
|
|
210 /* True iff we are about to fork off a synchronous process or if we
|
|
211 are waiting for it. */
|
|
212 extern volatile int synch_process_alive;
|
|
213
|
|
214 /* Nonzero => this is a string explaining death of synchronous subprocess. */
|
|
215 extern const char *synch_process_death;
|
|
216
|
|
217 /* If synch_process_death is zero,
|
|
218 this is exit code of synchronous subprocess. */
|
|
219 extern int synch_process_retcode;
|
|
220
|
|
221 #endif
|
|
222
|
|
223
|
440
|
224 #endif /* INCLUDED_sysproc_h_ */
|