Rev | Author | # | Line |
---|---|---|---|
1 | perry | 1 | !!NAME |
2 | PerryLorier | 2 | wait4 - wait for process termination, BSD style |
1 | perry | 3 | !!SYNOPSIS |
2 | PerryLorier | 4 | #include <sys/types.h> |
5 | #include <sys/time.h> | ||
6 | #include <sys/resource.h> | ||
7 | #include <sys/wait.h> | ||
8 | __pid_t wait4(pid_t__ ''pid''__, int *__''status''__, int__ ''options''__, struct rusage *__''rusage''__)__ | ||
1 | perry | 9 | !!DESCRIPTION |
2 | PerryLorier | 10 | The __wait4__ function suspends execution of the current process until a child as specified by the ''pid'' argument has exited, or until a signal is delivered whose action is to terminate the current process or to call a signal handling function. If a child as requested by ''pid'' has already exited by the time of the call (a so-called "zombie" process), the function returns immediately. Any system resources used by the child are freed. |
1 | perry | 11 | |
12 | The value of ''pid'' can be one of: | ||
2 | PerryLorier | 13 | ;<-1:which means to wait for any child process whose process group ID is equal to the absolute value of ''pid''. |
14 | ;-1:which means to wait for any child process; this is equivalent to calling wait3(2). | ||
15 | ;0:which means to wait for any child process whose process group ID is equal to that of the calling process. | ||
16 | ;>0:which means to wait for the child whose process ID is equal to the value of ''pid''. | ||
1 | perry | 17 | |
2 | PerryLorier | 18 | The value of ''options'' is a bitwise OR of zero or more of the following constants: |
19 | ;__WNOHANG__: which means to return immediately if no child is there to be waited for. | ||
20 | ;__WUNTRACED__: which means to also return for children which are stopped, and whose status has not been reported. | ||
1 | perry | 21 | |
2 | PerryLorier | 22 | If ''status'' is not __NULL__, __wait3__ or __wait4__ store status information in the location pointed to by ''status''. |
1 | perry | 23 | |
2 | PerryLorier | 24 | This status can be evaluated with the following macros (these macros take the stat buffer (an __int__) as an argument -- not a pointer to the buffer!): |
1 | perry | 25 | |
2 | PerryLorier | 26 | ;__WIFEXITED(__''status''__)__; is non-zero if the child exited normally. |
27 | ;__WEXITSTATUS(__''status''__)__: evaluates to the least significant eight bits of the return code of the child which terminated, which may have been set as the argument to a call to exit(3) or as the argument for a __return__ statement in the main program. This macro can only be evaluated if __WIFEXITED__ returned non-zero. | ||
28 | ;__WIFSIGNALED(__''status''__)__: returns true if the child process exited because of a signal which was not caught. | ||
29 | ;__WTERMSIG(__''status''__)__: returns the number of the signal that caused the child process to terminate. This macro can only be evaluated if | ||
1 | perry | 30 | __WIFSIGNALED__ returned non-zero. |
2 | PerryLorier | 31 | ;__WIFSTOPPED(__''status''__)__: returns true if the child process which caused the return is currently stopped; this is only possible if the call was |
1 | perry | 32 | done using __WUNTRACED__. |
2 | PerryLorier | 33 | ;__WSTOPSIG(__''status''__)__:returns the number of the signal which caused the child to stop. This macro can only be evaluated if __WIFSTOPPED__ |
1 | perry | 34 | returned non-zero. |
35 | |||
2 | PerryLorier | 36 | If ''rusage'' is not __NULL__, the __struct rusage__ as defined in ''<sys/resource.h>'' it points to will be filled with accounting information. See |
1 | perry | 37 | getrusage(2) for details. |
2 | PerryLorier | 38 | |
1 | perry | 39 | !!RETURN VALUE |
2 | PerryLorier | 40 | The process ID of the child which exited, -1 on error (in particular, when no unwaited-for child processes of the specified kind exist) or zero if __WNOHANG__ was used and no child was available yet. In the latter two cases ''errno'' will be set appropriately. |
1 | perry | 41 | |
42 | !!ERRORS | ||
2 | PerryLorier | 43 | ;[ECHILD]: No unwaited-for child process as specified does exist. |
44 | ;[ERESTARTSYS]: if __WNOHANG__ was not set and an unblocked signal or a [SIGCHLD] was caught. This error is returned by the system call. The library interface is not allowed to return [ERESTARTSYS], but will return [EINTR]. | ||
1 | perry | 45 | |
46 | !!NOTE | ||
2 | PerryLorier | 47 | Including ''<sys/time.h>'' is not required these days, but increases portability. (Indeed, ''<sys/resource.h>'' defines the ''rusage'' structure with fields of type ''struct timeval'' defined in ''<sys/time.h>''.) |
1 | perry | 48 | !!CONFORMING TO |
2 | PerryLorier | 49 | SVr4, POSIX.1 |
1 | perry | 50 | |
51 | !!SEE ALSO | ||
2 | PerryLorier | 52 | signal(2), getrusage(2), wait(2), signal(7) |
lib/blame.php:177: Warning: Invalid argument supplied for foreach() (...repeated 4 times)