DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

wait(S-osr5)


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-osr5) 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-osr5), exit(S-osr5), fork(S-osr5), Intro(S-osr5), pause(S-osr5), ptrace(S-osr5), sigaction(S-osr5), signal(M), signal(S-osr5), waitpid(S-osr5)

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 .


© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005