On 2026-01-04 at 19:04 +0100, wrotycz wrote:
> There is an issue with lzip in windows where it complains about broken pipe 
> when it is cut, quote unquote, in half.
> ~~~
> $ ./clzip.exe -dc clzip-1.16-rc1.tar.lz | head -c 100000 > 100000
> clzip: Write error: Broken pipe
> ~~~
> 
> As far as I remember it does not happen in linux.
> 
> ~~~
> $ gzip -dc clzip-1.16-rc1.tar.gz | head -c 100000 > 100000; echo 
> "${PIPESTATUS[0]} ${PIPESTATUS[1]}"
> 141 0
> 
> $ ./clzip -dc clzip-1.16-rc1.tar.lz | head -c 100000 > 100000; echo 
> "${PIPESTATUS[0]} ${PIPESTATUS[1]}"
> 141 0
> ~~~
> 
> Sure enough, it does not complain, although g/c/l/zip exits with non-zero 
> status.
> 
> 
> But it does complain in windows.
> 
> ~~~
> $ gzip.exe -dc clzip-1.16-rc1.tar.gz | head -c 100000 > 100000; echo 
> "${PIPESTATUS[0]} ${PIPESTATUS[1]}"
> 141 0
> 
> $ bzip2.exe -dc clzip-1.16-rc1.tar.bz2 | head -c 100000 > 100000; echo 
> "${PIPESTATUS[0]} ${PIPESTATUS[1]}"
> 141 0
> 
> $ ./clzip.exe -dc clzip-1.16-rc1.tar.lz | head -c 100000 > 100000; echo 
> "${PIPESTATUS[0]} ${PIPESTATUS[1]}"
> clzip: Write error: Broken pipe
> 1 0
> 
> $ pigz.exe -dc clzip-1.16-rc1.tar.gz | head -c 100000 > 100000; echo 
> "${PIPESTATUS[0]} ${PIPESTATUS[1]}"
> pigz.exe: abort: write error on <stdout> (Invalid argument)
> 22 0
> ~~~
> 
> Although gzip/bzip2 does not. But pigz does.
> Its somewhat incosistent among compressors but apparently gzip and bzip2 deal 
> with it like in linux.
> 
> I dont know what to think of it myself.


On Linux SIGPIPE is killing the process before it can print anything.
On WIndows there's no SIGPIPE signal, so it simply fails on write.

clzip is only handling SGHUP, SIGINT and SIGTERM, so when it receives a
SIGPIPE signal the default action for this signal kills the process
(and I don't think it's a wrong behavior).

/tmp/clzip-1.16-rc1$ strace -e fork ./clzip -dc ../clzip-1.16-
rc1.tar.lz | head -c 2
cl--- SIGPIPE {si_signo=SIGPIPE, si_code=SI_USER, si_pid=1429,
si_uid=1000} ---
+++ killed by SIGPIPE +++


If you ignore SIGPIPE you will get the same behavior as in Windows:

/tmp/clzip-1.16-rc1$ bash -c "trap '' SIGPIPE; ./clzip -dc ../clzip-
1.16-rc1.tar.lz | head -c 2 "
clclzip: Write error: Broken pipe


Regards

Reply via email to