any2fasta
any2fasta copied to clipboard
Fix broken pipe error when piping to early-exit commands
The CI tests fail with "Unable to flush stdout: Broken pipe" when piping any2fasta to commands like grep -m 1 that exit after finding their first match.
Changes
- Ignore SIGPIPE signals to prevent immediate termination when the pipe reader closes
- Handle EPIPE errno gracefully in explicit STDOUT close, exiting cleanly instead of failing
- Use
POSIX::EPIPEconstant instead of hardcoded errno value
use POSIX qw(EPIPE);
$SIG{PIPE} = 'IGNORE';
# ... script body ...
close(STDOUT) or do {
exit(0) if $! == EPIPE;
die "Error closing stdout: $!\n";
};
This allows commands like any2fasta test.gbk | grep -m 1 pattern to exit cleanly without errors.
Original prompt
This section details on the original issue you should resolve
<issue_title>CI: Unable to flush stdout: Broken pipe</issue_title> <issue_description>I am getting this error in my tests in CI.yml Actions:
Unable to flush stdout: Broken pipe Error: Process completed with exit code 1.</issue_description>
Comments on the Issue (you are @copilot in this section)
- Fixes tseemann/any2fasta#31
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.