The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
wait.h File Reference

waiting for child processes. More...

#include <sys/types.h>

Go to the source code of this file.

Macros

#define WNOHANG   1
#define WUNTRACED   2
#define WCONTINUED   8
#define WIFEXITED(status)
#define WEXITSTATUS(status)
#define WIFSIGNALED(status)
#define WTERMSIG(status)
#define WIFSTOPPED(status)
#define WSTOPSIG(status)
#define WIFCONTINUED(status)

Functions

pid_t waitpid (pid_t pid, int *status, int options)
 wait for a child process to exit and reap it.
pid_t wait (int *status)
 wait for any child to exit and reap it.

Detailed Description

waiting for child processes.

the status word and the option values are ABI and must match the kernel side in src/kernel/process/wait_status.h.

Macro Definition Documentation

◆ WNOHANG

#define WNOHANG   1

◆ WUNTRACED

#define WUNTRACED   2

◆ WCONTINUED

#define WCONTINUED   8

◆ WIFEXITED

#define WIFEXITED ( status)
Value:
(((status) & 0x7f) == 0)

◆ WEXITSTATUS

#define WEXITSTATUS ( status)
Value:
(((status) >> 8) & 0xff)

◆ WIFSIGNALED

#define WIFSIGNALED ( status)
Value:
(((status) & 0x7f) != 0 && ((status) & 0x7f) != 0x7f)

◆ WTERMSIG

#define WTERMSIG ( status)
Value:
((status) & 0x7f)

◆ WIFSTOPPED

#define WIFSTOPPED ( status)
Value:
(((status) & 0xff) == 0x7f)

◆ WSTOPSIG

#define WSTOPSIG ( status)
Value:
(((status) >> 8) & 0xff)

◆ WIFCONTINUED

#define WIFCONTINUED ( status)
Value:
((status) == 0xffff)

Function Documentation

◆ waitpid()

pid_t waitpid ( pid_t pid,
int * status,
int options )

wait for a child process to exit and reap it.

Parameters
pida child's pid, or -1 for any child.
statusreceives the status word (may be NULL).
options0 or WNOHANG.
Returns
the reaped child's pid, 0 with WNOHANG if no matching child has exited yet, or -1 on error (errno set; ECHILD if there is no matching child).

◆ wait()

pid_t wait ( int * status)

wait for any child to exit and reap it.

Parameters
statusreceives the status word (may be NULL).
Returns
the child's pid, or -1 on error (errno set).