in reply to zcat pipe gives "gzip: stdout: Broken pipe" error
Difference: Your large program uses $SIG{ PIPE } = "IGNORE";.
Solution: Add local $SIG{ PIPE } = "DEFAULT"; in scope of your open. Alternatively, you could redirect zcat's STDERR to /dev/null.
Take a look at this:
seq 1000000000 | gzip | zcat | head
It should take a long time to generate and unzip that stream, but it doesn't.
$ time ( seq 1000000000 | gzip | zcat | head ) 1 2 3 4 5 6 7 8 9 10 real 0m0.051s user 0m0.056s sys 0m0.005s
This is what happens:
The above is what happens in your standalone script.
In your larger program, you appear to have used $SIG{ PIPE } = "IGNORE";. It's still just as quick, but the error message now appears.
$ seq 1000000000 | gzip | perl -e'$SIG{ PIPE } = "IGNORE"; exec("zcat" +)' | head 1 2 3 4 5 6 7 8 9 10 gzip: stdout: Broken pipe
This is what happens now:
Add local $SIG{ PIPE } = "DEFAULT"; in scope of your open.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: zcat pipe gives "gzip: stdout: Broken pipe" error
by NERDVANA (Priest) on Mar 26, 2025 at 14:51 UTC | |
by ikegami (Patriarch) on Mar 26, 2025 at 16:59 UTC |