DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

wait(S)


wait -- wait for child process to stop or terminate

Syntax

cc . . . -lc

#include <sys/types.h>
#include <sys/wait.h>

pid_t wait(int *stat_loc);

Description

wait suspends the calling process until one of its immediate children terminates or until a child that is being traced stops because it has received a signal. The wait system call returns prematurely if a signal is received. If any child process has stopped or terminated prior to the call on wait, return is immediate.

If wait returns because the status of a child process is available, it returns the process ID of the child process. If the calling process had specified a non-zero value for stat_loc, the status of the child process will be stored in the location pointed to by stat_loc. It may be evaluated with the following macros:

See waitpid(S) for details of these macros.

Return values

If wait returns due to the status of a child process being available, the process ID of the child is returned to the calling process. If it returns because of the delivery of a signal to the calling process, (pid)-1 is returned and errno set to EINTR. Otherwise, wait returns (pid_t)-1 and sets errno to identify the error.

Diagnostics

In the following conditions, wait fails and sets errno to:

[ECHILD]
The calling process has no existing unwaited-for child processes.

[EINTR]
The function was interrupted by a signal.

Files


/lib/libc.a
linking library

See also

exec(S), exit(S), fork(S), Intro(S), pause(S), ptrace(S), sigaction(S), signal(M), signal(S), waitpid(S)

Standards conformance

wait is conformant with:

AT&T SVID Issue 3;
X/Open Portability Guide Issue 4, Version 2 (Spec-1170)
X/Open Portability Guide, Issue 3, 1989 ;
IEEE POSIX Std 1003.1-1990 System Application Program Interface (API) [C Language] (ISO/IEC 9945-1) ; and NIST FIPS 151-1 .


© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003