posix-next API 0.1.0
Out-of-tree Zephyr POSIX module
Loading...
Searching...
No Matches
wait.h File Reference

POSIX declarations for waiting (<sys/wait.h>) More...

#include <signal.h>
#include <sys/types.h>
#include <zephyr/kernel.h>
Include dependency graph for wait.h:

Go to the source code of this file.

Macros

#define WCONTINUED   K_PROCESS_WCONTINUED
 Report status of any continued child process.
 
#define WNOHANG   K_PROCESS_WNOHANG
 Do not hang if no status is available; return immediately.
 
#define WUNTRACED   K_PROCESS_WUNTRACED
 Report status of stopped child process.
 
#define WEXITSTATUS(wstatus)   K_WEXITSTATUS(wstatus)
 Exit status of a child that exited normally.
 
#define WIFCONTINUED(wstatus)   ((wstatus) == 0xffff)
 True if the child has continued from a job control stop.
 
#define WIFEXITED(wstatus)   K_WIFEXITED(wstatus)
 True if the child exited normally.
 
#define WIFSIGNALED(wstatus)   K_WIFSIGNALED(wstatus)
 True if the child exited due to an uncaught signal.
 
#define WIFSTOPPED(wstatus)   (((wstatus) & 0xff) == 0x7f)
 True if the child is currently stopped.
 
#define WSTOPSIG(wstatus)   (((wstatus) >> 8) & 0xff)
 Signal number that caused the child to stop.
 
#define WTERMSIG(wstatus)   K_WTERMSIG(wstatus)
 Signal number that caused the child to terminate.
 
#define WEXITED   K_PROCESS_WEXITED
 Wait for processes that have exited.
 
#define WNOWAIT   K_PROCESS_WNOWAIT
 Report the status of a selected process, leaving it waitable.
 
#define WSTOPPED   K_PROCESS_WUNTRACED
 Wait for processes stopped by delivery of a signal.
 

Typedefs

typedef enum idtype idtype_t
 Identifier kind selecting the scope of a waitid() operation.
 
typedef int id_t
 
typedef int pid_t
 

Enumerations

enum  idtype { P_ALL , P_PID , P_PGID }
 Identifier kind selecting the scope of a waitid() operation. More...
 

Functions

pid_t wait (int *stat_loc)
 Wait for any child process to terminate.
 
int waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options)
 Wait for a child process matching idtype and id to change state.
 
pid_t waitpid (pid_t pid, int *stat_loc, int options)
 Wait for a child process to terminate.
 

Detailed Description

POSIX declarations for waiting (<sys/wait.h>)

See also
POSIX.1-2017 <sys/wait.h>

Definition in file wait.h.

Macro Definition Documentation

◆ WCONTINUED

#define WCONTINUED   K_PROCESS_WCONTINUED

Report status of any continued child process.

Definition at line 33 of file wait.h.

◆ WEXITED

#define WEXITED   K_PROCESS_WEXITED

Wait for processes that have exited.

Definition at line 58 of file wait.h.

◆ WEXITSTATUS

#define WEXITSTATUS (   wstatus)    K_WEXITSTATUS(wstatus)

Exit status of a child that exited normally.

Definition at line 41 of file wait.h.

◆ WIFCONTINUED

#define WIFCONTINUED (   wstatus)    ((wstatus) == 0xffff)

True if the child has continued from a job control stop.

Definition at line 44 of file wait.h.

◆ WIFEXITED

#define WIFEXITED (   wstatus)    K_WIFEXITED(wstatus)

True if the child exited normally.

Definition at line 47 of file wait.h.

◆ WIFSIGNALED

#define WIFSIGNALED (   wstatus)    K_WIFSIGNALED(wstatus)

True if the child exited due to an uncaught signal.

Definition at line 49 of file wait.h.

◆ WIFSTOPPED

#define WIFSTOPPED (   wstatus)    (((wstatus) & 0xff) == 0x7f)

True if the child is currently stopped.

Definition at line 51 of file wait.h.

◆ WNOHANG

#define WNOHANG   K_PROCESS_WNOHANG

Do not hang if no status is available; return immediately.

Definition at line 36 of file wait.h.

◆ WNOWAIT

#define WNOWAIT   K_PROCESS_WNOWAIT

Report the status of a selected process, leaving it waitable.

Definition at line 60 of file wait.h.

◆ WSTOPPED

#define WSTOPPED   K_PROCESS_WUNTRACED

Wait for processes stopped by delivery of a signal.

Definition at line 62 of file wait.h.

◆ WSTOPSIG

#define WSTOPSIG (   wstatus)    (((wstatus) >> 8) & 0xff)

Signal number that caused the child to stop.

Definition at line 53 of file wait.h.

◆ WTERMSIG

#define WTERMSIG (   wstatus)    K_WTERMSIG(wstatus)

Signal number that caused the child to terminate.

Definition at line 55 of file wait.h.

◆ WUNTRACED

#define WUNTRACED   K_PROCESS_WUNTRACED

Report status of stopped child process.

Definition at line 38 of file wait.h.

Typedef Documentation

◆ id_t

typedef int id_t

Definition at line 79 of file wait.h.

◆ idtype_t

typedef enum idtype idtype_t

Identifier kind selecting the scope of a waitid() operation.

◆ pid_t

typedef int pid_t

Definition at line 85 of file wait.h.

Enumeration Type Documentation

◆ idtype

enum idtype

Identifier kind selecting the scope of a waitid() operation.

Enumerator
P_ALL 

Wait for any child of the calling process.

P_PID 

Wait for the child with a specific process ID.

P_PGID 

Wait for any child in a specific process group.

Definition at line 66 of file wait.h.

Function Documentation

◆ wait()

pid_t wait ( int *  stat_loc)

Wait for any child process to terminate.

Parameters
[out]stat_loclocation in which to store the child's wait status; may be NULL.
Returns
the process ID of the reaped child on success, or -1 with errno set on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/wait.html

◆ waitid()

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

Wait for a child process matching idtype and id to change state.

Parameters
idtypescope of the wait operation (P_ALL, P_PID, or P_PGID).
idprocess ID or process group ID, according to idtype.
[out]infoplocation in which to store the child's status information.
optionsbitwise OR of WEXITED, WNOHANG, and WNOWAIT.
Returns
0 on success, or -1 with errno set on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/waitid.html

◆ waitpid()

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

Wait for a child process to terminate.

Parameters
pidchild selection: a process ID, -1 for any child, 0 for the caller's process group, or a negated process group ID.
[out]stat_loclocation in which to store the child's wait status; may be NULL.
optionsbitwise OR of WNOHANG and WUNTRACED.
Returns
the process ID of the child on success, or -1 with errno set on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/waitpid.html