Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

intro(2)

exec(2)

exit(2)

fork(2)

pause(3)

ptrace(2)

signal(2)

sigaction(2)

wait(2)

pause(3)

siginfo(5)

waitid(2)  —  System Calls

NAME

waitid − wait for child process to change state

SYNOPSIS

#include <sys/types.h>

#include <wait.h>

int waitid (
     idtype_t idtype,
     id_t        id,
     siginfo_t   ∗infop,
     int         options );

PARAMETERS

idtypeIdentifies the type of process to be affected.  Used with the id parameter, it suspends execution for the specified child process. 

idSpecifies either the process ID or process group ID of the child process.  Used with the idtype parameter, it suspends execution for the specified process. 

infopSpecifies a pointer to a siginfo_t structure. 

optionsSpecifies the conditions that must occur before a wait operation is performed by the waitid function. 

DESCRIPTION

The waitid function holds a calling process until the state of one of the child processes changes.  The current state of the child is recorded in a structure pointed to by the infop parameter.  If a child process changed state prior to the call to the waitid function, the waitid function returns immediately. 

The idtype and id parameters determine which child process the waitid function is to act upon. 

       •If the idtype parameter is P_PID, the waitid function waits for the child with a process ID equal to (pid_t)id. 

       •If the idtype parameter is P_PGID, the waitid function waits for any child with a process group ID equal to (pid_t)id. 

       •If the idtype parameter is P_ALL, the waitid function waits for any children and the id parameter is ignored. 

The options parameter specifies the conditions that must occur before a wait operation is performed by the waitid function.  To specify a condition, OR any of the following flags:

WEXITEDWait for process(es) to exit. 

WTRAPPED
Wait for traced process(es) to become trapped or reach a breakpoint [see ptrace(2)]. 

WSTOPPED
Wait for and return the process status of any child that has stopped upon receipt of a signal.

WCONTINUED
Return the status for any child that was stopped and has been continued.

WNOHANG
Specifies an immediate return if there is no wait for a child process.

WNOWAIT
Keep the process in a waitable state.  Another wait may occur with the same results.

The infop parameter must point to a siginfo_t structure as defined in siginfo(5).  This structure contains the status of why a process is in a wait state. 

RETURN VALUE

If the waitid function because of a change in the state of one of its children, a value of zero (0) is returned.  Otherwise, a value of −1 is returned and errno is set to indicate the error. 

ERRORS

This function fails under the following conditions:

[EFAULT]Specifies that the infop parameter points to an invalid address. 

[EINTR]Specifies that the waitid function was interrupted by the receipt of a signal from the calling process. 

[EINVAL]Specifies that an invalid value was used with the options parameter. 

[EINVAL]Specifies that idtype and id parameters specify an invalid set of processes. 

[ECHILD]Specifies that the set of processes specified by the idtype and id parameters does not contain any unwaited for processes. 

RELATED INFORMATION

Functions: intro(2), exec(2), exit(2), fork(2), pause(3), ptrace(2), signal(2), sigaction(2), wait(2). 

Routines: pause(3). 

Files: siginfo(5). 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026