* movemail.c:
[bpt/emacs.git] / src / syswait.h
CommitLineData
43626ea4 1/* Define wait system call interface for Emacs.
429ab54e 2 Copyright (C) 1993, 1994, 1995, 2000, 2001, 2002, 2003, 2004,
8cabe764 3 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
43626ea4
RS
4
5This file is part of GNU Emacs.
6
7GNU Emacs is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
684d6f5b 9the Free Software Foundation; either version 3, or (at your option)
43626ea4
RS
10any later version.
11
12GNU Emacs is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU Emacs; see the file COPYING. If not, write to
4fc5845f
LK
19the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20Boston, MA 02110-1301, USA. */
43626ea4
RS
21
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. */
25
d72c1cad
DL
26#ifndef EMACS_SYSWAIT_H
27#define EMACS_SYSWAIT_H
28
43626ea4 29#ifndef VMS
d72c1cad 30
557713d8
RS
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. */
d72c1cad
DL
34
35#if 1
d72c1cad 36#include <sys/types.h>
1f0bb0ab 37
3bddb272 38#ifdef HAVE_SYS_WAIT_H /* We have sys/wait.h with POSIXoid definitions. */
d72c1cad 39#include <sys/wait.h>
557713d8
RS
40#endif /* !HAVE_SYS_WAIT_H */
41
1f0bb0ab
DL
42#ifndef WCOREDUMP /* not POSIX */
43#define WCOREDUMP(status) ((status) & 0x80)
d72c1cad 44#endif
557713d8 45#ifndef WEXITSTATUS
1f0bb0ab 46#define WEXITSTATUS(status) (((status) & 0xff00) >> 8)
557713d8
RS
47#endif
48#ifndef WIFEXITED
1f0bb0ab 49#define WIFEXITED(status) (WTERMSIG(status) == 0)
557713d8
RS
50#endif
51#ifndef WIFSTOPPED
1f0bb0ab 52#define WIFSTOPPED(status) (((status) & 0xff) == 0x7f)
557713d8
RS
53#endif
54#ifndef WIFSIGNALED
1f0bb0ab 55#define WIFSIGNALED(status) (!WIFSTOPPED(status) && !WIFEXITED(status))
557713d8
RS
56#endif
57#ifndef WSTOPSIG
1f0bb0ab 58#define WSTOPSIG(status) WEXITSTATUS(status)
557713d8
RS
59#endif
60#ifndef WTERMSIG
1f0bb0ab 61#define WTERMSIG(status) ((status) & 0x7f)
557713d8 62#endif
d72c1cad 63
1f0bb0ab
DL
64#undef WAITTYPE
65#define WAITTYPE int
66#undef WRETCODE
67#define WRETCODE(status) WEXITSTATUS (status)
d72c1cad 68
557713d8 69#else /* 0 */
d72c1cad 70
43626ea4 71#ifndef WAITTYPE
da149a8f
RS
72
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)
79
80#else /* not WAIT_USE_INT */
81
e39a993c 82#if (!defined (BSD_SYSTEM) && !(defined (HPUX) && !defined (NOMULTIPLEJOBS)) && !defined (HAVE_WAIT_HEADER))
43626ea4
RS
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)
1f0bb0ab 89#define WTERMSIG(w) (w & 0177)
43626ea4
RS
90#ifndef WCOREDUMP
91#define WCOREDUMP(w) ((w&0200) != 0)
92#endif
da149a8f 93
177c0ea7 94#else
da149a8f 95
43626ea4
RS
96#ifdef BSD4_1
97#include <wait.h>
98#else
99#include <sys/wait.h>
100#endif /* not BSD 4.1 */
101
102#define WAITTYPE union wait
103#define WRETCODE(w) w.w_retcode
4f480b74 104#undef WCOREDUMP /* Later BSDs define this name differently. */
43626ea4
RS
105#define WCOREDUMP(w) w.w_coredump
106
b01b093a 107#if defined (HPUX) || defined (convex)
43626ea4 108/* HPUX version 7 has broken definitions of these. */
b01b093a 109/* pvogel@convex.com says the convex does too. */
43626ea4
RS
110#undef WTERMSIG
111#undef WSTOPSIG
112#undef WIFSTOPPED
113#undef WIFSIGNALED
114#undef WIFEXITED
b01b093a 115#endif /* HPUX | convex */
43626ea4
RS
116
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
e39a993c 132#endif /* BSD_SYSTEM || HPUX */
da149a8f 133#endif /* not WAIT_USE_INT */
43626ea4 134#endif /* no WAITTYPE */
da149a8f 135
557713d8 136#endif /* 0 */
d72c1cad 137
43626ea4 138#else /* VMS */
da149a8f 139
43626ea4
RS
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"
da149a8f 152
43626ea4 153#endif /* VMS */
d72c1cad
DL
154
155#endif /* EMACS_SYSWAIT_H */
ab5796a9
MB
156
157/* arch-tag: 7e5d9719-ec66-4b6f-89bb-563eea16a899
158 (do not change this comment) */