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)
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
30 /* Try the approach recommended by autoconf. If this doesn't cause
31 trouble anywhere, remove the original code, which is #if'd out
37 #define WRETCODE(w) WEXITSTATUS (w)
39 #include <sys/types.h>
44 #if defined (HPUX) || defined (convex)
45 /* HPUX version 7 has broken definitions of these. */
46 /* pvogel@convex.com says the convex does too. */
52 #endif /* HPUX || convex */
55 # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
58 # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
61 #define WIFSTOPPED(w) ((w&0377) == 0177)
64 #define WIFSIGNALED(w) ((w&0377) != 0177 && (w&~0377) == 0)
67 #define WIFEXITED(w) ((w&0377) == 0)
70 #define WRETCODE(w) (w >> 8)
73 #define WSTOPSIG(w) (w >> 8)
76 #define WTERMSIG(w) (w & 0377)
79 #define WCOREDUMP(w) ((w&0200) != 0)
87 /* Some systems have union wait in their header, but we should use
88 int regardless of that. */
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))
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)
104 #define WCOREDUMP(w) ((w&0200) != 0)
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. */
128 #endif /* HPUX | convex */
131 #define WTERMSIG(w) w.w_termsig
134 #define WSTOPSIG(w) w.w_stopsig
137 #define WIFSTOPPED(w) (WTERMSIG (w) == 0177)
140 #define WIFSIGNALED(w) (WTERMSIG (w) != 0177 && (WSTOPSIG (w)) == 0)
143 #define WIFEXITED(w) (WTERMSIG (w) == 0)
145 #endif /* BSD_SYSTEM || UNIPLUS || STRIDE || HPUX */
146 #endif /* not WAIT_USE_INT */
147 #endif /* no WAITTYPE */
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)
168 #endif /* EMACS_SYSWAIT_H */