wait.2: POSIX.1-2008 TC1 clarifies treatment of 'si_pid' for waitid() WNOHANG

Reported-by: Ильдар Низамов <niya3@mail.ru>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2017-09-14 12:35:29 +02:00
parent bc4590d93d
commit 59e30f70a8
1 changed files with 25 additions and 6 deletions

View File

@ -350,16 +350,35 @@ the state of the
.I siginfo_t
structure pointed to by
.I infop
is unspecified.
.\" POSIX.1-2001 leaves this possibility unspecified; most
.\" implementations (including Linux) zero out the structure
.\" in this case, but at least one implementation (AIX 5.1)
.\" does not -- MTK Nov 04
To distinguish this case from that where a child was in a
depends on the implementation.
To (portably) distinguish this case from that where a child was in a
waitable state, zero out the
.I si_pid
field before the call and check for a nonzero value in this field
after the call returns.
.PP
POSIX.1-2008 Technical Corrigendum 1 (2013) adds the requirement that when
.B WNOHANG
is specified in
.I options
and there were no children in a waitable state, then
.BR waitid ()
should zero out the
.I si_pid
and
.I si_signo
fields of the structure.
On Linux and other implementations that adhere to this requirement,
it is not necessary to zero out the
.I si_pid
field before calling
.BR waitid ().
However,
not all implementations follow the POSIX.1 specification on this point.
.\" POSIX.1-2001 leaves this possibility unspecified; most
.\" implementations (including Linux) zero out the structure
.\" in this case, but at least one implementation (AIX 5.1)
.\" does not -- MTK Nov 04
.SH RETURN VALUE
.BR wait ():
on success, returns the process ID of the terminated child;