(codepage-setup): Fix typo in obsolescence declaration.
[emacs.git] / src / syswait.h
blob6bfab435459f120eab704c7ae343218be89a0c5f
1 /* Define wait system call interface for Emacs.
2 Copyright (C) 1993, 1994, 1995, 2000, 2001, 2002, 2003, 2004,
3 2005, 2006, 2007, 2008 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 3, or (at your option)
10 any later version.
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
29 #ifndef VMS
31 /* This is now really the approach recommended by Autoconf. If this
32 doesn't cause trouble anywhere, remove the original code, which is
33 #if'd out below. */
35 #if 1
36 #include <sys/types.h>
38 #ifdef HAVE_SYS_WAIT_H /* We have sys/wait.h with POSIXoid definitions. */
39 #include <sys/wait.h>
40 #endif /* !HAVE_SYS_WAIT_H */
42 #ifndef WCOREDUMP /* not POSIX */
43 #define WCOREDUMP(status) ((status) & 0x80)
44 #endif
45 #ifndef WEXITSTATUS
46 #define WEXITSTATUS(status) (((status) & 0xff00) >> 8)
47 #endif
48 #ifndef WIFEXITED
49 #define WIFEXITED(status) (WTERMSIG(status) == 0)
50 #endif
51 #ifndef WIFSTOPPED
52 #define WIFSTOPPED(status) (((status) & 0xff) == 0x7f)
53 #endif
54 #ifndef WIFSIGNALED
55 #define WIFSIGNALED(status) (!WIFSTOPPED(status) && !WIFEXITED(status))
56 #endif
57 #ifndef WSTOPSIG
58 #define WSTOPSIG(status) WEXITSTATUS(status)
59 #endif
60 #ifndef WTERMSIG
61 #define WTERMSIG(status) ((status) & 0x7f)
62 #endif
64 #undef WAITTYPE
65 #define WAITTYPE int
66 #undef WRETCODE
67 #define WRETCODE(status) WEXITSTATUS (status)
69 #else /* 0 */
71 #ifndef WAITTYPE
73 #ifdef WAIT_USE_INT
74 /* Some systems have union wait in their header, but we should use
75 int regardless of that. */
76 #include <sys/wait.h>
77 #define WAITTYPE int
78 #define WRETCODE(w) WEXITSTATUS (w)
80 #else /* not WAIT_USE_INT */
82 #if (!defined (BSD_SYSTEM) && !(defined (HPUX) && !defined (NOMULTIPLEJOBS)) && !defined (HAVE_WAIT_HEADER))
83 #define WAITTYPE int
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)
90 #ifndef WCOREDUMP
91 #define WCOREDUMP(w) ((w&0200) != 0)
92 #endif
94 #else
96 #ifdef BSD4_1
97 #include <wait.h>
98 #else
99 #include <sys/wait.h>
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. */
110 #undef WTERMSIG
111 #undef WSTOPSIG
112 #undef WIFSTOPPED
113 #undef WIFSIGNALED
114 #undef WIFEXITED
115 #endif /* HPUX | convex */
117 #ifndef WTERMSIG
118 #define WTERMSIG(w) w.w_termsig
119 #endif
120 #ifndef WSTOPSIG
121 #define WSTOPSIG(w) w.w_stopsig
122 #endif
123 #ifndef WIFSTOPPED
124 #define WIFSTOPPED(w) (WTERMSIG (w) == 0177)
125 #endif
126 #ifndef WIFSIGNALED
127 #define WIFSIGNALED(w) (WTERMSIG (w) != 0177 && (WSTOPSIG (w)) == 0)
128 #endif
129 #ifndef WIFEXITED
130 #define WIFEXITED(w) (WTERMSIG (w) == 0)
131 #endif
132 #endif /* BSD_SYSTEM || HPUX */
133 #endif /* not WAIT_USE_INT */
134 #endif /* no WAITTYPE */
136 #endif /* 0 */
138 #else /* VMS */
140 #define WAITTYPE int
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)
148 #include <ssdef.h>
149 #include <iodef.h>
150 #include <clidef.h>
151 #include "vmsproc.h"
153 #endif /* VMS */
155 #endif /* EMACS_SYSWAIT_H */
157 /* arch-tag: 7e5d9719-ec66-4b6f-89bb-563eea16a899
158 (do not change this comment) */