Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion codecov_cli/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import logging
import pathlib
import signal
import sys
import typing

import click
Expand Down Expand Up @@ -93,7 +95,23 @@ def cli(


def run():
cli(obj={})
# Restore default SIGPIPE handling on POSIX so the OS terminates the
# process cleanly when a pipe reader closes early, before Python raises
# BrokenPipeError inside Click's echo().
if hasattr(signal, "SIGPIPE"):
signal.signal(signal.SIGPIPE, signal.SIG_DFL)

try:
cli(obj={})
except BrokenPipeError:
# Swallow broken-pipe errors that occur when stdout/stderr is closed
# by the consuming process (e.g. piped into `head`). Flush remaining
# output silently and exit with a non-zero code.
try:
sys.stderr.flush()
except BrokenPipeError:
pass
sys.exit(1)


if __name__ == "__main__":
Expand Down
Loading