[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: standards/51024 (NetBSD misses the mandatory waitid() syscall)
David Holland <dholland-bugs%netbsd.org@localhost> wrote:
> The following reply was made to PR standards/51024; it has been noted by GNATS.
> From: David Holland <dholland-bugs%netbsd.org@localhost>
> To: gnats-bugs%NetBSD.org@localhost
> Subject: Re: standards/51024 (NetBSD misses the mandatory waitid() syscall)
> Date: Wed, 20 Apr 2016 08:50:11 +0000
> On Mon, Apr 04, 2016 at 04:10:01PM +0000, Joerg Schilling wrote:
> > The value of status may be 0, EXIT_SUCCESS, EXIT_FAILURE, or any other
> > value, though only the least significant 8 bits (that is, status & 0377)
> > shall be available from wait() and waitpid(); the full value shall
> > be available from waitid() and in the siginfo_t passed to a
> > signal handler for SIGCHLD.
> Am I supposed to interpret this to *prohibit* wait() from returning
> more than 8 bits of status?
Do you confuse "status" with the exit status of the child?
wait() and waitpid() are deprecated historic interfaces that return a pointer
to 16 bits of "stat-loc" data. The interface they implement was never designed
to return more than 8 bits of the exit status from the child.
The POSIX standard indeed disallows WEXITSTATUS(statloc) to return more than 8
bits from the child's exit code and even when you try to make use of the fact
that stat-loc was and is an "int", you would not be able to include more than
24 bits from the child's exit code in that int.
NOTE: while the definition of the behavior for WEXITSTATUS() could have been
different, there are some people who are in fear that the shell could
unexpectedly report a value != 0 in $? by default when the child calls
BTW: here is the history of the interfaces:
In 1980, a group of former AT&T employees created "Charles River Data Systems"
that offered "UNOS", the first UNIX clone. This OS did come with an interface
int *pidp; /* where to fill in pid */
int *statp; /* where to fill in status */
Returns the following values, depending on why cwait() came
< 0 error (no children)
0 normal termination, exit code of child
3 trap, particular trap in status
4 suspended, can be resumed or killed
5 exec failure, standard system error code in status
6 syserr, error detected in kernel, standard error code
This interface already returned the full 32 bits from the child's exit code.
Later in 1989, AT&T added waitid() to UNIX for SVr4 and offered a very similar
interface to "cwait". It just moved the exit reason, the pid and the child exit
status into a structgure.
EMail:joerg%schily.net@localhost (home) Jörg Schilling D-13353 Berlin
joerg.schilling%fokus.fraunhofer.de@localhost (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.org/private/ http://sourceforge.net/projects/schilytools/files/'
Main Index |
Thread Index |