samtools / bcftools

This is the official development repository for BCFtools. See installation instructions and other documentation here http://samtools.github.io/bcftools/howtos/install.html
http://samtools.github.io/bcftools/
Other
674 stars 240 forks source link

bcftools does not appear to handle SIGPIPE gracefully #1999

Closed anderspitman closed 1 year ago

anderspitman commented 1 year ago

To reproduce:

bcftools view <vcf with more than 5 lines> | head -n 5

After head finishes processing 5 lines and exits, bcftools will attempt to continue writing to the pipe and receive SIGPIPE from the OS, and exit with code 141. This breaks scripts that use set -eo pipefail.

Background info:

https://stackoverflow.com/questions/19120263/why-exit-code-141-with-grep-q

https://github.com/samtools/samtools/issues/1567

http://www.pixelbeat.org/programming/sigpipe_handling.html

pd3 commented 1 year ago

I don't understand what is the problem. This seems to work alright

$ cat test.sh
#!/bin/bash
set -eo pipefail
bcftools view test.vcf | head -1
echo "done"

$ ./test.sh
##fileformat=VCFv4.2
done
pd3 commented 1 year ago

I believe this is resolved, please complain if not