Remove __need macros from signal.h.
[glibc.git] / posix / sys / wait.h
blobd5b7e4d8d4f4ab88c2ceb8fe12f03551580de1a9
1 /* Copyright (C) 1991-2017 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library 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 GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
19 * POSIX Standard: 3.2.1 Wait for Process Termination <sys/wait.h>
22 #ifndef _SYS_WAIT_H
23 #define _SYS_WAIT_H 1
25 #include <features.h>
27 __BEGIN_DECLS
29 #include <signal.h>
31 /* These macros could also be defined in <stdlib.h>. */
32 #if !defined _STDLIB_H || (!defined __USE_XOPEN && !defined __USE_XOPEN2K8)
33 /* This will define the `W*' macros for the flag
34 bits to `waitpid', `wait3', and `wait4'. */
35 # include <bits/waitflags.h>
37 /* This will define all the `__W*' macros. */
38 # include <bits/waitstatus.h>
40 # define WEXITSTATUS(status) __WEXITSTATUS (status)
41 # define WTERMSIG(status) __WTERMSIG (status)
42 # define WSTOPSIG(status) __WSTOPSIG (status)
43 # define WIFEXITED(status) __WIFEXITED (status)
44 # define WIFSIGNALED(status) __WIFSIGNALED (status)
45 # define WIFSTOPPED(status) __WIFSTOPPED (status)
46 # ifdef __WIFCONTINUED
47 # define WIFCONTINUED(status) __WIFCONTINUED (status)
48 # endif
49 #endif /* <stdlib.h> not included. */
51 #ifdef __USE_MISC
52 # define WCOREFLAG __WCOREFLAG
53 # define WCOREDUMP(status) __WCOREDUMP (status)
54 # define W_EXITCODE(ret, sig) __W_EXITCODE (ret, sig)
55 # define W_STOPCODE(sig) __W_STOPCODE (sig)
56 #endif
58 /* The following values are used by the `waitid' function. */
59 #if defined __USE_XOPEN || defined __USE_XOPEN2K8
60 typedef enum
62 P_ALL, /* Wait for any child. */
63 P_PID, /* Wait for specified process. */
64 P_PGID /* Wait for members of process group. */
65 } idtype_t;
66 #endif
69 /* Wait for a child to die. When one does, put its status in *STAT_LOC
70 and return its process ID. For errors, return (pid_t) -1.
72 This function is a cancellation point and therefore not marked with
73 __THROW. */
74 extern __pid_t wait (int *__stat_loc);
76 #ifdef __USE_MISC
77 /* Special values for the PID argument to `waitpid' and `wait4'. */
78 # define WAIT_ANY (-1) /* Any process. */
79 # define WAIT_MYPGRP 0 /* Any process in my process group. */
80 #endif
82 /* Wait for a child matching PID to die.
83 If PID is greater than 0, match any process whose process ID is PID.
84 If PID is (pid_t) -1, match any process.
85 If PID is (pid_t) 0, match any process with the
86 same process group as the current process.
87 If PID is less than -1, match any process whose
88 process group is the absolute value of PID.
89 If the WNOHANG bit is set in OPTIONS, and that child
90 is not already dead, return (pid_t) 0. If successful,
91 return PID and store the dead child's status in STAT_LOC.
92 Return (pid_t) -1 for errors. If the WUNTRACED bit is
93 set in OPTIONS, return status for stopped children; otherwise don't.
95 This function is a cancellation point and therefore not marked with
96 __THROW. */
97 extern __pid_t waitpid (__pid_t __pid, int *__stat_loc, int __options);
99 #if defined __USE_XOPEN || defined __USE_XOPEN2K8
100 # ifndef __id_t_defined
101 # include <bits/types.h>
102 typedef __id_t id_t;
103 # define __id_t_defined
104 # endif
106 # include <bits/types/siginfo_t.h>
108 /* Wait for a childing matching IDTYPE and ID to change the status and
109 place appropriate information in *INFOP.
110 If IDTYPE is P_PID, match any process whose process ID is ID.
111 If IDTYPE is P_PGID, match any process whose process group is ID.
112 If IDTYPE is P_ALL, match any process.
113 If the WNOHANG bit is set in OPTIONS, and that child
114 is not already dead, clear *INFOP and return 0. If successful, store
115 exit code and status in *INFOP.
117 This function is a cancellation point and therefore not marked with
118 __THROW. */
119 extern int waitid (idtype_t __idtype, __id_t __id, siginfo_t *__infop,
120 int __options);
121 #endif
123 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
124 /* This being here makes the prototypes valid whether or not
125 we have already included <sys/resource.h> to define `struct rusage'. */
126 struct rusage;
128 /* Wait for a child to exit. When one does, put its status in *STAT_LOC and
129 return its process ID. For errors return (pid_t) -1. If USAGE is not
130 nil, store information about the child's resource usage there. If the
131 WUNTRACED bit is set in OPTIONS, return status for stopped children;
132 otherwise don't. */
133 extern __pid_t wait3 (int *__stat_loc, int __options,
134 struct rusage * __usage) __THROWNL;
135 #endif
137 #ifdef __USE_MISC
138 /* PID is like waitpid. Other args are like wait3. */
139 extern __pid_t wait4 (__pid_t __pid, int *__stat_loc, int __options,
140 struct rusage *__usage) __THROWNL;
141 #endif /* Use misc. */
144 __END_DECLS
146 #endif /* sys/wait.h */