From: "Michael Kerrisk (man-pages)" <mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Sloane Bernstein <sloane-Fu4SeaK3EASsTnJN9+BGXg@public.gmane.org>
Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: WEXITSTATUS() under wait(2) has ambiguous description
Date: Sat, 6 Aug 2016 09:52:17 +1000 [thread overview]
Message-ID: <dba9f0e5-54df-a987-9aa3-d246c73e133a@gmail.com> (raw)
In-Reply-To: <DED29858-0AB0-4BCE-A80E-998C67542001-Fu4SeaK3EASsTnJN9+BGXg@public.gmane.org>
Hello Sloane,
On 08/04/2016 10:55 PM, Sloane Bernstein wrote:
> 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.
So, the "status" that you point is indeed a typo. I accidentally
injected that typo during a recent global edit. It should read "status"
and I've now fixed the page to reflect that, so the text now reads:
WEXITSTATUS(wstatus)
returns the exit status of the child. This consists of the
least significant 8 bits of the status 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.
Thanks for the report!
Cheers,
Michael
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2016-08-05 23:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-04 12:55 WEXITSTATUS() under wait(2) has ambiguous description Sloane Bernstein
[not found] ` <DED29858-0AB0-4BCE-A80E-998C67542001-Fu4SeaK3EASsTnJN9+BGXg@public.gmane.org>
2016-08-05 23:52 ` Michael Kerrisk (man-pages) [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dba9f0e5-54df-a987-9aa3-d246c73e133a@gmail.com \
--to=mtk.manpages-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=sloane-Fu4SeaK3EASsTnJN9+BGXg@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).