On Wed, Dec 05, 2012 at 08:11:24AM +0100, Michal Kubeček wrote:
On Tuesday 04 of December 2012 13:05EN, Giacomo Comes wrote:
But if I add the option -q to grep: if cpio --quiet -t
&2 ; else echo false-$? >&2 ; fi | grep -q libz the output is: false-141 instead of the correct one: true-0
Return code 141 means the process was killed by signal 141 - 128 = 13 which is SIGPIPE. And grep(1) tells you that with "-q", grep exits immediately as soon as it finds a match. Unfortunately cpio doesn't handle SIGPIPE so it fails when grep exits.
You can either try to report it as a cpio bug or use a simple workaround like
if ... fi | cat | grep -q libz
Anyway, this is definitely not a kernel problem.
There is certanly a SIGPIPE issue here, but I'm not sure cpio is the one
to blame, or at least the only one, for the following reasons:
1) the script fails if I run it on openSUSE 12.2 using the cpio binary from 11.3, but
it doesn't fail if I run it on openSUSE 11.3 using the cpio binary from 12.2
(the version of cpio is 2.11 since openSUSE 11.3)
2) simply running:
cpio --quiet -t