Bug 981443 - wait vs. invalid pid/job spec: man page update OR wait builtin fix might be needed
wait vs. invalid pid/job spec: man page update OR wait builtin fix might be n...
Status: ASSIGNED
Product: Fedora
Classification: Fedora
Component: bash (Show other bugs)
26
Unspecified Unspecified
low Severity low
: ---
: ---
Assigned To: Siteshwar Vashisht
BaseOS QE - Apps
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-07-04 13:54 EDT by Jan Pokorný
Modified: 2017-02-28 04:34 EST (History)
8 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Jan Pokorný 2013-07-04 13:54:08 EDT
Just noticed this discrepancy man page vs. reality:

> SHELL BUILTIN COMMANDS
> [...]
> wait [n ...]
>        [...] the return status is zero. [...] the return status is 127.
>        Otherwise, the return status is the exit status of the last
>        process or job waited for.

plus

> EXIT STATUS
> [...]
> All builtins return an exit status of 2 to indicate incorrect usage.


vs.


$ wait foo; echo $?
> -bash: wait: `foo': not a pid or valid job spec
> 1


As per man page, I would expect the above command to be instance
of incorrect usage (as no additional possibility is enumerated
at the wait description), hence would expect 2 to be the exit status.

Apparently, there is an inherent danger of exit status aliasing when
the last process or job waited for exits with 1 (or 2).
Using 2 instead of 1 would IMHO be (to limited extent) safer in this
regard, as quite common C-based program's logic is to use just
0 (EXIT_SUCCESS) and 1 (EXIT_FAILURE).
Comment 2 Roman Rakus 2013-07-09 07:15:21 EDT
Looks like all (or majority) builtins return 1 on error. Easier is to change man page. Will ask upstream.
Comment 11 Siteshwar Vashisht 2017-01-18 11:21:03 EST
I presume this can be closed with manpage update from comment 7. Is it ok with you ?
Comment 12 Jan Pokorný 2017-01-19 11:04:31 EST
Well, the expected outcome really is that wait builtin in bash won't
return 1 because of the common failure exit code aliasing issue
described in [comment 0].

Reading http://pubs.opengroup.org/onlinepubs/9699919799/utilities/wait.html
my intepretation is that it would be entirely OK if it returned 127
in case of nonsensical PID operand.

The referred man page update is no remedy here, I am afraid.
Comment 13 Siteshwar Vashisht 2017-01-31 06:58:54 EST
Moving this bug to rawhide for further discussion.
Comment 14 Fedora End Of Life 2017-02-28 04:34:17 EST
This bug appears to have been reported against 'rawhide' during the Fedora 26 development cycle.
Changing version to '26'.

Note You need to log in before you can comment on or make changes to this bug.