modernc.org/cc@v1.0.1/v2/headers/linux_amd64/usr/include/sys/wait.h (about) 1 /* Copyright (C) 1991-2015 Free Software Foundation, Inc. 2 This file is part of the GNU C Library. 3 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. 8 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. 13 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/>. */ 17 18 /* 19 * POSIX Standard: 3.2.1 Wait for Process Termination <sys/wait.h> 20 */ 21 22 #ifndef _SYS_WAIT_H 23 #define _SYS_WAIT_H 1 24 25 #include <features.h> 26 27 __BEGIN_DECLS 28 #include <signal.h> 29 /* These macros could also be defined in <stdlib.h>. */ 30 #if !defined _STDLIB_H || (!defined __USE_XOPEN && !defined __USE_XOPEN2K8) 31 /* This will define the `W*' macros for the flag 32 bits to `waitpid', `wait3', and `wait4'. */ 33 # include <bits/waitflags.h> 34 # ifdef __USE_MISC 35 /* Lots of hair to allow traditional BSD use of `union wait' 36 as well as POSIX.1 use of `int' for the status word. */ 37 # if defined __GNUC__ && !defined __cplusplus 38 # define __WAIT_INT(status) \ 39 (__extension__ (((union { __typeof(status) __in; int __i; }) \ 40 { .__in = (status) }).__i)) 41 # else 42 # define __WAIT_INT(status) (*(const int *) &(status)) 43 # endif 44 /* This is the type of the argument to `wait'. The funky union 45 causes redeclarations with either `int *' or `union wait *' to be 46 allowed without complaint. __WAIT_STATUS_DEFN is the type used in 47 the actual function definitions. */ 48 # if !defined __GNUC__ || __GNUC__ < 2 || defined __cplusplus 49 # define __WAIT_STATUS void * 50 # define __WAIT_STATUS_DEFN void * 51 # else 52 /* This works in GCC 2.6.1 and later. */ 53 typedef union { 54 union wait *__uptr; 55 int *__iptr; 56 } __WAIT_STATUS __attribute__ ((__transparent_union__)); 57 # define __WAIT_STATUS_DEFN int * 58 # endif 59 60 # else /* Don't use misc. */ 61 # define __WAIT_INT(status) (status) 62 # define __WAIT_STATUS int * 63 # define __WAIT_STATUS_DEFN int * 64 # endif /* Use misc. */ 65 /* This will define all the `__W*' macros. */ 66 # include <bits/waitstatus.h> 67 # define WEXITSTATUS(status) __WEXITSTATUS (__WAIT_INT (status)) 68 # define WTERMSIG(status) __WTERMSIG (__WAIT_INT (status)) 69 # define WSTOPSIG(status) __WSTOPSIG (__WAIT_INT (status)) 70 # define WIFEXITED(status) __WIFEXITED (__WAIT_INT (status)) 71 # define WIFSIGNALED(status) __WIFSIGNALED (__WAIT_INT (status)) 72 # define WIFSTOPPED(status) __WIFSTOPPED (__WAIT_INT (status)) 73 # ifdef __WIFCONTINUED 74 # define WIFCONTINUED(status) __WIFCONTINUED (__WAIT_INT (status)) 75 # endif 76 #endif /* <stdlib.h> not included. */ 77 #ifdef __USE_MISC 78 # define WCOREFLAG __WCOREFLAG 79 # define WCOREDUMP(status) __WCOREDUMP (__WAIT_INT (status)) 80 # define W_EXITCODE(ret, sig) __W_EXITCODE (ret, sig) 81 # define W_STOPCODE(sig) __W_STOPCODE (sig) 82 #endif 83 /* The following values are used by the `waitid' function. */ 84 #if defined __USE_XOPEN || defined __USE_XOPEN2K8 85 typedef enum { 86 P_ALL, /* Wait for any child. */ 87 P_PID, /* Wait for specified process. */ 88 P_PGID /* Wait for members of process group. */ 89 } idtype_t; 90 #endif 91 92 /* Wait for a child to die. When one does, put its status in *STAT_LOC 93 and return its process ID. For errors, return (pid_t) -1. 94 95 This function is a cancellation point and therefore not marked with 96 __THROW. */ 97 extern __pid_t wait(__WAIT_STATUS __stat_loc); 98 99 #ifdef __USE_MISC 100 /* Special values for the PID argument to `waitpid' and `wait4'. */ 101 # define WAIT_ANY (-1) /* Any process. */ 102 # define WAIT_MYPGRP 0 /* Any process in my process group. */ 103 #endif 104 105 /* Wait for a child matching PID to die. 106 If PID is greater than 0, match any process whose process ID is PID. 107 If PID is (pid_t) -1, match any process. 108 If PID is (pid_t) 0, match any process with the 109 same process group as the current process. 110 If PID is less than -1, match any process whose 111 process group is the absolute value of PID. 112 If the WNOHANG bit is set in OPTIONS, and that child 113 is not already dead, return (pid_t) 0. If successful, 114 return PID and store the dead child's status in STAT_LOC. 115 Return (pid_t) -1 for errors. If the WUNTRACED bit is 116 set in OPTIONS, return status for stopped children; otherwise don't. 117 118 This function is a cancellation point and therefore not marked with 119 __THROW. */ 120 extern __pid_t waitpid(__pid_t __pid, int *__stat_loc, int __options); 121 122 #if defined __USE_XOPEN || defined __USE_XOPEN2K8 123 # ifndef __id_t_defined 124 # include <bits/types.h> 125 typedef __id_t id_t; 126 # define __id_t_defined 127 # endif 128 129 # define __need_siginfo_t 130 # include <bits/siginfo.h> 131 132 /* Wait for a childing matching IDTYPE and ID to change the status and 133 place appropriate information in *INFOP. 134 If IDTYPE is P_PID, match any process whose process ID is ID. 135 If IDTYPE is P_PGID, match any process whose process group is ID. 136 If IDTYPE is P_ALL, match any process. 137 If the WNOHANG bit is set in OPTIONS, and that child 138 is not already dead, clear *INFOP and return 0. If successful, store 139 exit code and status in *INFOP. 140 141 This function is a cancellation point and therefore not marked with 142 __THROW. */ 143 extern int waitid(idtype_t __idtype, __id_t __id, siginfo_t * __infop, int __options); 144 #endif 145 146 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED 147 /* This being here makes the prototypes valid whether or not 148 we have already included <sys/resource.h> to define `struct rusage'. */ 149 struct rusage; 150 151 /* Wait for a child to exit. When one does, put its status in *STAT_LOC and 152 return its process ID. For errors return (pid_t) -1. If USAGE is not 153 nil, store information about the child's resource usage there. If the 154 WUNTRACED bit is set in OPTIONS, return status for stopped children; 155 otherwise don't. */ 156 extern __pid_t wait3(__WAIT_STATUS __stat_loc, int __options, struct rusage *__usage) __THROWNL; 157 #endif 158 159 #ifdef __USE_MISC 160 /* PID is like waitpid. Other args are like wait3. */ 161 extern __pid_t wait4(__pid_t __pid, __WAIT_STATUS __stat_loc, int __options, struct rusage *__usage) __THROWNL; 162 #endif /* Use misc. */ 163 164 __END_DECLS 165 #endif /* sys/wait.h */