1 /* Define wait system call interface for Emacs.
2 Copyright (C) 1993, 1994, 1995, 2000, 2002, 2003, 2004,
3 2005, 2006 Free Software Foundation, Inc.
5 This file is part of GNU Emacs.
7 GNU Emacs is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
22 /* Define the structure that the wait system call stores.
23 On many systems, there is a structure defined for this.
24 But on vanilla-ish USG systems there is not. */
26 #ifndef EMACS_SYSWAIT_H
27 #define EMACS_SYSWAIT_H
31 /* This is now really the approach recommended by Autoconf. If this
32 doesn't cause trouble anywhere, remove the original code, which is
36 #include <sys/types.h>
38 #ifdef HAVE_SYS_WAIT_H /* We have sys/wait.h with POSIXoid definitions. */
40 #endif /* !HAVE_SYS_WAIT_H */
42 #ifndef WCOREDUMP /* not POSIX */
43 #define WCOREDUMP(status) ((status) & 0x80)
46 #define WEXITSTATUS(status) (((status) & 0xff00) >> 8)
49 #define WIFEXITED(status) (WTERMSIG(status) == 0)
52 #define WIFSTOPPED(status) (((status) & 0xff) == 0x7f)
55 #define WIFSIGNALED(status) (!WIFSTOPPED(status) && !WIFEXITED(status))
58 #define WSTOPSIG(status) WEXITSTATUS(status)
61 #define WTERMSIG(status) ((status) & 0x7f)
67 #define WRETCODE(status) WEXITSTATUS (status)
74 /* Some systems have union wait in their header, but we should use
75 int regardless of that. */
78 #define WRETCODE(w) WEXITSTATUS (w)
80 #else /* not WAIT_USE_INT */
82 #if (!defined (BSD_SYSTEM) && !defined (UNIPLUS) && !defined (STRIDE) && !(defined (HPUX) && !defined (NOMULTIPLEJOBS)) && !defined (HAVE_WAIT_HEADER))
84 #define WIFSTOPPED(w) ((w&0377) == 0177)
85 #define WIFSIGNALED(w) ((w&0377) != 0177 && (w&~0377) == 0)
86 #define WIFEXITED(w) ((w&0377) == 0)
87 #define WRETCODE(w) (w >> 8)
88 #define WSTOPSIG(w) (w >> 8)
89 #define WTERMSIG(w) (w & 0177)
91 #define WCOREDUMP(w) ((w&0200) != 0)
100 #endif /* not BSD 4.1 */
102 #define WAITTYPE union wait
103 #define WRETCODE(w) w.w_retcode
104 #undef WCOREDUMP /* Later BSDs define this name differently. */
105 #define WCOREDUMP(w) w.w_coredump
107 #if defined (HPUX) || defined (convex)
108 /* HPUX version 7 has broken definitions of these. */
109 /* pvogel@convex.com says the convex does too. */
115 #endif /* HPUX | convex */
118 #define WTERMSIG(w) w.w_termsig
121 #define WSTOPSIG(w) w.w_stopsig
124 #define WIFSTOPPED(w) (WTERMSIG (w) == 0177)
127 #define WIFSIGNALED(w) (WTERMSIG (w) != 0177 && (WSTOPSIG (w)) == 0)
130 #define WIFEXITED(w) (WTERMSIG (w) == 0)
132 #endif /* BSD_SYSTEM || UNIPLUS || STRIDE || HPUX */
133 #endif /* not WAIT_USE_INT */
134 #endif /* no WAITTYPE */
141 #define WIFSTOPPED(w) 0
142 #define WIFSIGNALED(w) 0
143 #define WIFEXITED(w) ((w) != -1)
144 #define WRETCODE(w) (w)
145 #define WSTOPSIG(w) (w)
146 #define WCOREDUMP(w) 0
147 #define WTERMSIG(w) (w)
155 #endif /* EMACS_SYSWAIT_H */
157 /* arch-tag: 7e5d9719-ec66-4b6f-89bb-563eea16a899
158 (do not change this comment) */