Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix pipefail exit status of signalled process to be > 256
Koichi Nakashima (@ko1nksm) reports: > $ set -o pipefail > $ seq 1000000 | head > /dev/null > $ echo $? > 13 > > The seq command terminated by SIGPIPE, but the exit status is 13. > The reason I think this is problematic is that we don't know that > the seq command terminated by a signal (and I wish ksh had > PIPESTATUS). And POSIX specifies an exit status of 128 or higher > when exiting on a signal. > > From my investigation, it appears that this behavior was changed > in ksh93u+, although I am not sure if this was intentional or > not. On ksh93s+ (debian 6.0) and ksh93t+ (OpenIndiana 2013.08) it > works as follows: > > $ set -o pipefail > $ seq 1000000 | head > /dev/null > $ echo $? > 269 I was testing my stash of historic ksh versions compiled on Debian arm64 from the ksh93-history repo. Version 93u 2011-03-10 and before do not have the bug; the bug is present as of 93u+ 2011-04-15, which rewrote the code for the pipefail option. src/cmd/ksh93/sh/jobs.c: job_unpost(): - When saving a process' exit status for the pipefail option, also set the 9th bit (a.k.a. SH_EXITSIG) if the process was signalled. Discussion: #755 (comment)
- Loading branch information