Pwait

Section: Feb. 1, 1993 (2)
Updated: MiNT Programmer's Manual
Index Return to Main Contents
 

NAME

Pwait, Pwait3, Pwaitpid - get exit status of children  

SYNOPSIS

LONG Pwait();
LONG Pwait3( WORD flag, LONG *rusage );
LONG Pwaitpid( WORD pid, WORD flag, LONG *rusage );
 

DESCRIPTION

Pwaitpid attempts to determine the exit code for certain stopped children or children that have terminated. pid determines which children's exit status are of interest. If pid is -1, all children are of interest. If pid is less than -1, only children whose process group matches -pid are of interest. If pid is equal to 0, only children with the same process group ID as the caller are of interest. If pid is greater than 0, only the child with the given process ID is of interest.

If bit 1 of flag is set, then children that are stopped due to job control are reported; otherwise only children that have actually terminated are reported. A stopped process will be reported at most once (unless it is re-started and stopped again); similarly a terminated process will be reported only once.

If the process does have children which are of interest to the caller (as specified by pid), but none are currently stopped or terminated and not yet waited for, then the behavior of Pwaitpid is controlled by bit 0 of flag. If it is clear, the function will wait until some child is stopped or terminates; if it is set, the function will return immediately.

The rusage parameter, if non-zero, should point to two long words, into which information about the child's CPU time usage is placed, as follows:

rusage[0]: milliseconds spent by child in user space
rusage[1]: milliseconds spent by child in kernel space

The Pwait3() system call is equivalent to Pwaitpid(-1, flag, (LONG *)0), and is provided for backward compatibility. The Pwait() system call is equivalent to Pwaitpid(-1, 2, (LONG *)0) and is provided only for compatibility with old applications; new applications should not use this system call.  

RETURNS

If a child process is found which matches the pid specification given, its process id is placed in the upper 16 bits of the 32 bit value returned, and its exit status (as passed to Pterm or Ptermres, as determined implicitly by Pterm0, or as determined by the type of signal that stopped or killed the process) is placed in the lower 16 bits. If the process was stopped or terminated by signal n, then its exit status will be ( n<< 8 ) | x. where x is 127 if the process was stopped and 0 if the process was terminated.

0 if bit 0 of flag is set and the Pwaitpid system call would have otherwise blocked waiting for a child to exit or stop.

EFILNF if no unwaited for children exist which are "of interest" as specified by pid.  

SEE ALSO

Pexec(2), Pterm(2), Pterm0(2), Ptermres(2)  

BUGS

Note that Pwait waits for stopped processes, unlike the POSIX wait function. Pwait is obsolete anyway, and library writers are advised to use Pwaitpid or Pwait3 to implement POSIX wait.


 

Index

NAME
SYNOPSIS
DESCRIPTION
RETURNS
SEE ALSO
BUGS

This document was created by man2html, using the manual pages.
Time: 08:57:57 GMT, February 14, 2025