Skip to content

Fix broken pipe error when piping to early-exit commands#32

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-stdout-broken-pipe
Draft

Fix broken pipe error when piping to early-exit commands#32
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-stdout-broken-pipe

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 23, 2025

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::EPIPE constant 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)


💡 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.

Copilot AI and others added 2 commits December 23, 2025 05:50
… early

Co-authored-by: tseemann <453972+tseemann@users.noreply.github.com>
…able code

Co-authored-by: tseemann <453972+tseemann@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix CI issue with unable to flush stdout broken pipe Fix broken pipe error when piping to early-exit commands Dec 23, 2025
Copilot AI requested a review from tseemann December 23, 2025 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI: Unable to flush stdout: Broken pipe

2 participants