1WAITID(3P) POSIX Programmer's Manual WAITID(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 waitid - wait for a child process to change state
13
15 #include <sys/wait.h>
16
17 int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options);
18
19
21 The waitid() function shall suspend the calling thread until one child
22 of the process containing the calling thread changes state. It records
23 the current state of a child in the structure pointed to by infop. If a
24 child process changed state prior to the call to waitid(), waitid()
25 shall return immediately. If more than one thread is suspended in
26 wait() or waitpid() waiting for termination of the same process,
27 exactly one thread shall return the process status at the time of the
28 target process termination.
29
30 The idtype and id arguments are used to specify which children waitid()
31 waits for.
32
33 If idtype is P_PID, waitid() shall wait for the child with a process ID
34 equal to (pid_t)id.
35
36 If idtype is P_PGID, waitid() shall wait for any child with a process
37 group ID equal to (pid_t)id.
38
39 If idtype is P_ALL, waitid() shall wait for any children and id is
40 ignored.
41
42 The options argument is used to specify which state changes waitid()
43 shall wait for. It is formed by OR'ing together one or more of the fol‐
44 lowing flags:
45
46 WEXITED
47 Wait for processes that have exited.
48
49 WSTOPPED
50 Status shall be returned for any child that has stopped upon
51 receipt of a signal.
52
53 WCONTINUED
54 Status shall be returned for any child that was stopped and has
55 been continued.
56
57 WNOHANG
58 Return immediately if there are no children to wait for.
59
60 WNOWAIT
61 Keep the process whose status is returned in infop in a waitable
62 state. This shall not affect the state of the process; the
63 process may be waited for again after this call completes.
64
65
66 The application shall ensure that the infop argument points to a sig‐
67 info_t structure. If waitid() returns because a child process was found
68 that satisfied the conditions indicated by the arguments idtype and
69 options, then the structure pointed to by infop shall be filled in by
70 the system with the status of the process. The si_signo member shall
71 always be equal to SIGCHLD.
72
74 If WNOHANG was specified and there are no children to wait for, 0 shall
75 be returned. If waitid() returns due to the change of state of one of
76 its children, 0 shall be returned. Otherwise, -1 shall be returned and
77 errno set to indicate the error.
78
80 The waitid() function shall fail if:
81
82 ECHILD The calling process has no existing unwaited-for child pro‐
83 cesses.
84
85 EINTR The waitid() function was interrupted by a signal.
86
87 EINVAL An invalid value was specified for options, or idtype and id
88 specify an invalid set of processes.
89
90
91 The following sections are informative.
92
94 None.
95
97 None.
98
100 None.
101
103 None.
104
106 exec(), exit(), wait(), the Base Definitions volume of
107 IEEE Std 1003.1-2001, <sys/wait.h>
108
110 Portions of this text are reprinted and reproduced in electronic form
111 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
112 -- Portable Operating System Interface (POSIX), The Open Group Base
113 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
114 Electrical and Electronics Engineers, Inc and The Open Group. In the
115 event of any discrepancy between this version and the original IEEE and
116 The Open Group Standard, the original IEEE and The Open Group Standard
117 is the referee document. The original Standard can be obtained online
118 at http://www.opengroup.org/unix/online.html .
119
120
121
122IEEE/The Open Group 2003 WAITID(3P)