Annotation of 43BSDTahoe/man/man2/wait.2, revision 1.1.1.1

1.1       root        1: .\" Copyright (c) 1980 Regents of the University of California.
                      2: .\" All rights reserved.  The Berkeley software License Agreement
                      3: .\" specifies the terms and conditions for redistribution.
                      4: .\"
                      5: .\"    @(#)wait.2      6.2 (Berkeley) 6/30/85
                      6: .\"
                      7: .TH WAIT 2 "June 30, 1985"
                      8: .UC 4
                      9: .SH NAME
                     10: wait, wait3 \- wait for process to terminate
                     11: .SH SYNOPSIS
                     12: .ft B
                     13: .nf
                     14: #include <sys/wait.h>
                     15: .PP
                     16: .ft B
                     17: pid = wait(status)
                     18: int pid;
                     19: union wait *status;
                     20: .PP
                     21: .ft B
                     22: pid = wait(0)
                     23: int pid;
                     24: .PP
                     25: .ft B
                     26: #include <sys/time.h>
                     27: #include <sys/resource.h>
                     28: .PP
                     29: .ft B
                     30: pid = wait3(status, options, rusage)
                     31: int pid;
                     32: union wait *status;
                     33: int options;
                     34: struct rusage *rusage;
                     35: .fi
                     36: .SH DESCRIPTION
                     37: .I Wait
                     38: causes its caller to delay until a signal is received or
                     39: one of its child
                     40: processes terminates.
                     41: If any child has died since the last
                     42: .IR wait ,
                     43: return is immediate, returning the process id and
                     44: exit status of one of the terminated
                     45: children.
                     46: If there are no children, return is immediate with
                     47: the value \-1 returned.
                     48: .PP
                     49: On return from a successful 
                     50: .I wait
                     51: call, 
                     52: .I status
                     53: is nonzero, and the high byte of 
                     54: .I status
                     55: contains the low byte of the argument to
                     56: .I exit
                     57: supplied by the child process;
                     58: the low byte of 
                     59: .I status
                     60: contains the termination status of the process.
                     61: A more precise definition of the
                     62: .I status
                     63: word is given in
                     64: .RI < sys/wait.h >.
                     65: .PP
                     66: .I Wait3
                     67: provides an alternate interface for programs
                     68: that must not block when collecting the status
                     69: of child processes.  The
                     70: .I status
                     71: parameter is defined as above.  The
                     72: .I options
                     73: parameter is used to indicate the call should not block if
                     74: there are no processes that wish to report status (WNOHANG),
                     75: and/or that children of the current process that are stopped
                     76: due to a SIGTTIN, SIGTTOU, SIGTSTP, or SIGSTOP signal should also have
                     77: their status reported (WUNTRACED).  If
                     78: .I rusage
                     79: is non-zero, a summary of the resources used by the terminated
                     80: process and all its
                     81: children is returned (this information is currently not available
                     82: for stopped processes).
                     83: .PP
                     84: When the WNOHANG option is specified and no processes
                     85: wish to report status, 
                     86: .I wait3
                     87: returns a 
                     88: .I pid
                     89: of 0.  The WNOHANG and WUNTRACED options may be combined by 
                     90: .IR or 'ing
                     91: the two values.
                     92: .SH NOTES
                     93: See
                     94: .IR sigvec (2)
                     95: for a list of termination statuses (signals);
                     96: 0 status indicates normal termination.
                     97: A special status (0177) is returned for a stopped process
                     98: that has not terminated and can be restarted;
                     99: see
                    100: .IR ptrace (2).
                    101: If the 0200 bit of the termination status
                    102: is set,
                    103: a core image of the process was produced
                    104: by the system.
                    105: .PP
                    106: If the parent process terminates without
                    107: waiting on its children,
                    108: the initialization process
                    109: (process ID = 1)
                    110: inherits the children.
                    111: .PP
                    112: .I Wait
                    113: and
                    114: .I wait3
                    115: are automatically restarted when a process receives a
                    116: signal while awaiting termination of a child process.
                    117: .SH "RETURN VALUE
                    118: If \fIwait\fP returns due to a stopped
                    119: or terminated child process, the process ID of the child
                    120: is returned to the calling process.  Otherwise, a value of \-1
                    121: is returned and \fIerrno\fP is set to indicate the error.
                    122: .PP
                    123: .I Wait3
                    124: returns \-1 if there are no children not previously waited
                    125: for;  0 is returned if WNOHANG is specified and there are
                    126: no stopped or exited children.
                    127: .SH ERRORS
                    128: .I Wait
                    129: will fail and return immediately if one or more of the following
                    130: are true:
                    131: .TP 15
                    132: [ECHILD]
                    133: The calling process has no existing unwaited-for
                    134: child processes.
                    135: .TP 15
                    136: [EFAULT]
                    137: The \fIstatus\fP or \fIrusage\fP arguments point to an illegal address.
                    138: .SH "SEE ALSO"
                    139: exit(2)

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.