Wait for a child process to stop or terminate
#include <sys/types.h> #include <sys/wait.h> pid_t waitpid( pid_t pid, int * stat_loc, int options );
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The waitpid() function suspends execution of the calling thread until status information from one of its terminated child processes is available, or until the delivery of a signal whose action is either to terminate the process or execute a signal handler. If status information is available prior to the call to waitpid(), the return is immediate.
|If the parent process sets the action for SIGCHLD to SIG_IGN, its children won't enter the zombie state, and it won't be able to use the wait*() functions to wait on their deaths.|
The waitpid() function behaves the same as wait() when passed a pid argument of -1, and the options argument has a value of zero.
Only one of the WIFEXITED(stat_val) and WIFSIGNALED(stat_val) macros can evaluate to a nonzero value.
The process ID of the terminating child process on success. If waitpid() is invoked with WNOHANG set in options, it has at least one child process specified by pid for which status isn't available, and status isn't available for any process specified by pid, a value of zero is returned. On delivery of a signal, waitpid() returns -1, and errno is set to EINTR.
spawn(), wait(), wait3(), wait4(), waitid()
Processes and Threads chapter of Getting Started with QNX Neutrino
“Detecting process termination” in the “Processes” chapter of the QNX Neutrino Programmer's Guide