regex: port to Stratus OpenVOS
[gnulib.git] / lib / sys_wait.in.h
1 /* A POSIX-like <sys/wait.h>.
2    Copyright (C) 2001-2003, 2005-2011 Free Software Foundation, Inc.
3
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 2, or (at your option)
7    any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program; if not, write to the Free Software Foundation,
16    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
17
18
19 #ifndef _@GUARD_PREFIX@_SYS_WAIT_H
20
21 #if __GNUC__ >= 3
22 @PRAGMA_SYSTEM_HEADER@
23 #endif
24 @PRAGMA_COLUMNS@
25
26 /* The include_next requires a split double-inclusion guard.  */
27 #if !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
28 # @INCLUDE_NEXT@ @NEXT_SYS_WAIT_H@
29 #endif
30
31 #ifndef _@GUARD_PREFIX@_SYS_WAIT_H
32 #define _@GUARD_PREFIX@_SYS_WAIT_H
33
34 /* Get pid_t.  */
35 #include <sys/types.h>
36
37
38 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
39
40 /* The definition of _GL_WARN_ON_USE is copied here.  */
41
42
43 #if !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
44 /* Unix API.  */
45
46 /* The following macros apply to an argument x, that is a status of a process,
47    as returned by waitpid().
48    On nearly all systems, including Linux/x86, WEXITSTATUS are bits 15..8 and
49    WTERMSIG are bits 7..0, while BeOS uses the opposite.  Therefore programs
50    have to use the abstract macros.  */
51
52 /* For valid x, exactly one of WIFSIGNALED(x), WIFEXITED(x), WIFSTOPPED(x)
53    is true.  */
54 # ifndef WIFSIGNALED
55 #  define WIFSIGNALED(x) (WTERMSIG (x) != 0 && WTERMSIG(x) != 0x7f)
56 # endif
57 # ifndef WIFEXITED
58 #  define WIFEXITED(x) (WTERMSIG (x) == 0)
59 # endif
60 # ifndef WIFSTOPPED
61 #  define WIFSTOPPED(x) (WTERMSIG (x) == 0x7f)
62 # endif
63
64 /* The termination signal. Only to be accessed if WIFSIGNALED(x) is true.  */
65 # ifndef WTERMSIG
66 #  define WTERMSIG(x) ((x) & 0x7f)
67 # endif
68
69 /* The exit status. Only to be accessed if WIFEXITED(x) is true.  */
70 # ifndef WEXITSTATUS
71 #  define WEXITSTATUS(x) (((x) >> 8) & 0xff)
72 # endif
73
74 /* The stopping signal. Only to be accessed if WIFSTOPPED(x) is true.  */
75 # ifndef WSTOPSIG
76 #  define WSTOPSIG(x) (((x) >> 8) & 0x7f)
77 # endif
78
79 /* True if the process dumped core.  Not standardized by POSIX.  */
80 # ifndef WCOREDUMP
81 #  define WCOREDUMP(x) ((x) & 0x80)
82 # endif
83
84 #else
85 /* Native Windows API.  */
86
87 # include <signal.h> /* for SIGTERM */
88
89 /* The following macros apply to an argument x, that is a status of a process,
90    as returned by waitpid() or, equivalently, _cwait() or GetExitCodeProcess().
91    This value is simply an 'int', not composed of bit fields.  */
92
93 /* When an unhandled fatal signal terminates a process, the exit code is 3.  */
94 # define WIFSIGNALED(x) ((x) == 3)
95 # define WIFEXITED(x) ((x) != 3)
96 # define WIFSTOPPED(x) 0
97
98 /* The signal that terminated a process is not known posthum.  */
99 # define WTERMSIG(x) SIGTERM
100
101 # define WEXITSTATUS(x) (x)
102
103 /* There are no stopping signals.  */
104 # define WSTOPSIG(x) 0
105
106 /* There are no core dumps.  */
107 # define WCOREDUMP(x) 0
108
109 #endif
110
111
112 /* Declarations of functions.  */
113
114 #if @GNULIB_WAITPID@
115 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
116 _GL_FUNCDECL_SYS (waitpid, pid_t, (pid_t pid, int *statusp, int options));
117 # endif
118 _GL_CXXALIAS_SYS (waitpid, pid_t, (pid_t pid, int *statusp, int options));
119 _GL_CXXALIASWARN (waitpid);
120 #elif defined GNULIB_POSIXCHECK
121 # undef waitpid
122 # if HAVE_RAW_DECL_WAITPID
123 _GL_WARN_ON_USE (waitpid, "waitpid is unportable - "
124                  "use gnulib module sys_wait for portability");
125 # endif
126 #endif
127
128
129 #endif /* _@GUARD_PREFIX@_SYS_WAIT_H */
130 #endif /* _@GUARD_PREFIX@_SYS_WAIT_H */