Name wait3, wait4 — wait for process to change state, BSD style Synopsis#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/wait.h>
DESCRIPTIONThe Other than the use of the wait3(status, options, rusage);
is equivalent to: waitpid(−1, status, options);
Similarly, the following wait4(pid, status, options, rusage);
is equivalent to: waitpid(pid, status, options);
In other words, If
The wait3 function suspends execution of the current process until a child 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 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. 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. The value of pid can be one of:
The value of options is a bitwise OR of zero or more of the following constants:
If status is not NULL, wait3 or wait4 store status information in the location pointed to by status. 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!):
If rusage is not NULL, the struct rusage as defined in <sys/resource.h> it points to will be filled with accounting information. See getrusage(2) for details. RETURN VALUEThe 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. ERRORS
SEE ALSO |
等待子进程结束
最新推荐文章于 2021-05-01 16:39:12 发布