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.