*** empty log message ***
[emacs.git] / src / syswait.h
blobd3edfdf0768c8381f25e6bac9b98cda613176d26
1 /* Define wait system call interface for Emacs.
2 Copyright (C) 1993, 1994, 1995, 2000 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* Define the structure that the wait system call stores.
22 On many systems, there is a structure defined for this.
23 But on vanilla-ish USG systems there is not. */
25 #ifndef EMACS_SYSWAIT_H
26 #define EMACS_SYSWAIT_H
28 #ifndef VMS
30 /* Try the approach recommended by autoconf. If this doesn't cause
31 trouble anywhere, remove the original code, which is #if'd out
32 below. */
34 #if 1
35 #undef WAITTYPE
36 #define WAITTYPE int
37 #define WRETCODE(w) WEXITSTATUS (w)
39 #include <sys/types.h>
40 #if HAVE_SYS_WAIT_H
41 #include <sys/wait.h>
42 #endif
44 #if defined (HPUX) || defined (convex)
45 /* HPUX version 7 has broken definitions of these. */
46 /* pvogel@convex.com says the convex does too. */
47 #undef WTERMSIG
48 #undef WSTOPSIG
49 #undef WIFSTOPPED
50 #undef WIFSIGNALED
51 #undef WIFEXITED
52 #endif /* HPUX || convex */
54 #ifndef WEXITSTATUS
55 # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
56 #endif
57 #ifndef WIFEXITED
58 # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
59 #endif
60 #ifndef WIFSTOPPED
61 #define WIFSTOPPED(w) ((w&0377) == 0177)
62 #endif
63 #ifndef WIFSIGNALED
64 #define WIFSIGNALED(w) ((w&0377) != 0177 && (w&~0377) == 0)
65 #endif
66 #ifndef WIFEXITED
67 #define WIFEXITED(w) ((w&0377) == 0)
68 #endif
69 #ifndef WRETCODE
70 #define WRETCODE(w) (w >> 8)
71 #endif
72 #ifndef WSTOPSIG
73 #define WSTOPSIG(w) (w >> 8)
74 #endif
75 #ifndef WTERMSIG
76 #define WTERMSIG(w) (w & 0377)
77 #endif
78 #ifndef WCOREDUMP
79 #define WCOREDUMP(w) ((w&0200) != 0)
80 #endif
82 #else /* !1 */
84 #ifndef WAITTYPE
86 #ifdef WAIT_USE_INT
87 /* Some systems have union wait in their header, but we should use
88 int regardless of that. */
89 #include <sys/wait.h>
90 #define WAITTYPE int
91 #define WRETCODE(w) WEXITSTATUS (w)
93 #else /* not WAIT_USE_INT */
95 #if (!defined (BSD_SYSTEM) && !defined (UNIPLUS) && !defined (STRIDE) && !(defined (HPUX) && !defined (NOMULTIPLEJOBS)) && !defined (HAVE_WAIT_HEADER))
96 #define WAITTYPE int
97 #define WIFSTOPPED(w) ((w&0377) == 0177)
98 #define WIFSIGNALED(w) ((w&0377) != 0177 && (w&~0377) == 0)
99 #define WIFEXITED(w) ((w&0377) == 0)
100 #define WRETCODE(w) (w >> 8)
101 #define WSTOPSIG(w) (w >> 8)
102 #define WTERMSIG(w) (w & 0377)
103 #ifndef WCOREDUMP
104 #define WCOREDUMP(w) ((w&0200) != 0)
105 #endif
107 #else
109 #ifdef BSD4_1
110 #include <wait.h>
111 #else
112 #include <sys/wait.h>
113 #endif /* not BSD 4.1 */
115 #define WAITTYPE union wait
116 #define WRETCODE(w) w.w_retcode
117 #undef WCOREDUMP /* Later BSDs define this name differently. */
118 #define WCOREDUMP(w) w.w_coredump
120 #if defined (HPUX) || defined (convex)
121 /* HPUX version 7 has broken definitions of these. */
122 /* pvogel@convex.com says the convex does too. */
123 #undef WTERMSIG
124 #undef WSTOPSIG
125 #undef WIFSTOPPED
126 #undef WIFSIGNALED
127 #undef WIFEXITED
128 #endif /* HPUX | convex */
130 #ifndef WTERMSIG
131 #define WTERMSIG(w) w.w_termsig
132 #endif
133 #ifndef WSTOPSIG
134 #define WSTOPSIG(w) w.w_stopsig
135 #endif
136 #ifndef WIFSTOPPED
137 #define WIFSTOPPED(w) (WTERMSIG (w) == 0177)
138 #endif
139 #ifndef WIFSIGNALED
140 #define WIFSIGNALED(w) (WTERMSIG (w) != 0177 && (WSTOPSIG (w)) == 0)
141 #endif
142 #ifndef WIFEXITED
143 #define WIFEXITED(w) (WTERMSIG (w) == 0)
144 #endif
145 #endif /* BSD_SYSTEM || UNIPLUS || STRIDE || HPUX */
146 #endif /* not WAIT_USE_INT */
147 #endif /* no WAITTYPE */
149 #endif /* 1 */
151 #else /* VMS */
153 #define WAITTYPE int
154 #define WIFSTOPPED(w) 0
155 #define WIFSIGNALED(w) 0
156 #define WIFEXITED(w) ((w) != -1)
157 #define WRETCODE(w) (w)
158 #define WSTOPSIG(w) (w)
159 #define WCOREDUMP(w) 0
160 #define WTERMSIG(w) (w)
161 #include <ssdef.h>
162 #include <iodef.h>
163 #include <clidef.h>
164 #include "vmsproc.h"
166 #endif /* VMS */
168 #endif /* EMACS_SYSWAIT_H */