Is there a way to make sure 141 exit status is resulted when pipeline is
From:
Peng Yu
Subject:
Is there a way to make sure 141 exit status is resulted when pipeline is terminated prematurelly?
Date:
Tue, 6 Oct 2020 17:20:08 -0500
Hi,
The following examples show that 141 is not always resulted when a
pipeline is terminated prematurelly. But I'd like to make sure any
script which calls a pipeline can determine whether the pipeline is
terminated prematurally. Is there a way to obtain such info in the
script? Thanks.
$ seq 10 | head -n 3; declare -p PIPESTATUS
1
2
3
declare -a PIPESTATUS=([0]="0" [1]="0")
$ seq 10000000 | head -n 3; declare -p PIPESTATUS
1
2
3
declare -a PIPESTATUS=([0]="141" [1]="0")
--
Regards,
Peng