WEXITSTATUS() under wait(2) has ambiguous description

From: Sloane Bernstein <hidden>
Date: 2016-08-04 12:55:36

Hello,

I believe that the description of the WEXITSTATUS() macro from the wait(2) manpage <http://man7.org/linux/man-pages/man2/wait.2.html> is either incorrect or very unclear:
       WEXITSTATUS(wstatus)

              returns the exit status of the child.  This consists of the
              least significant 8 bits of the wstatus argument that the
              child specified in a call to exit(3) or _exit(2) or as the
              argument for a return statement in main().  This macro should
              be employed only if WIFEXITED returned true.
The system's headers (it's a CentOS 6.8 system I pulled these from, IIRC) themselves define the macro as:
# define WEXITSTATUS(status)    __WEXITSTATUS (__WAIT_INT (status))
from sys/wait.h and
#define __WEXITSTATUS(status)   (((status) & 0xff00) >> 8)

but a simplistic reading of the manpage entry seems to imply that the latter definition should be:
#define __WEXITSTATUS(status)   ((status) & 0xff)

It isn't, of course. When the manpage refers to "the wstatus argument", it is too easy to associate it to the argument named in the declaration of the macro just above, rather than to the single argument of exit(3) or _exit(2) (which in both <http://man7.org/linux/man-pages/man3/exit.3.html> and <http://man7.org/linux/man-pages/man2/_exit.2.html>  is actually called "status", not "wstatus").

Because both exit(3) and _exit(2) only take a single argument, I would suggest striking "wstatus" from the text of the explanation of WEXITSTATUS(), since it is not ambiguous which argument of those functions is being referred to.

----------------------------------------
Sloane Bernstein
Technical Analyst III
cPanel, Inc.

Attachments

  • smime.p7s [application/pkcs7-signature] 3573 bytes
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help