wait(TCLX)

wait(TCLX)


wait -- wait for process created by execl to terminate

Syntax

wait [-nohang] [-untraced] [-pgroup] [pid]

Description

Waits for a process created with the execl command to terminate, either due to an untrapped signal or a call to an exit system call. If the process ID pid is specified, it waits for that process, otherwise it waits for any child process to terminate.

If -nohang is specified, then waiting for a process to terminate is not blocked. If no process is immediately available, it returns an empty list. If -untraced is specified then the status of child processes that are stopped and whose status has not yet been reported since they stopped, is also returned. If -pgroup is specified and pid is not specified, then it waits on any child process whose process group ID is the same as the calling process. If pid is specified with -pgroup, then it is taken as a process group ID, waiting on any process in that process group to terminate.

wait returns a list containing three elements: the first element is the process ID of the process that terminated. If the process exited normally, the second element is ``EXIT'', and the third contains the numeric exit code. If the process terminated due to a signal, the second element is ``SIG'', and the third contains the signal name. If the process is currently stopped (on systems that support SIGSTP), the second element is ``STOP'', followed by the signal name.

Notes

It is possible to wait on processes to terminate that were created in the background with the exec command. However, if any other exec command is executed after the process terminates, then the process status will be reset by the exec command and will not be available to the wait command.

See also