Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

log-search: Prevent BrokenPipeError exceptions when run with `head`.

Alex Vandiver3bf83e883025
diff --git a/scripts/log-search b/scripts/log-search
index 75bf63a8aeb..26026bb46d6 100755
--- a/scripts/log-search
+++ b/scripts/log-search
@@ -226,6 +226,12 @@ def main() -> None:
filter_types=filter_types,
use_color=use_color,
)
+ except BrokenPipeError:
+ # Python flushes standard streams on exit; redirect remaining output
+ # to devnull to avoid another BrokenPipeError at shutdown
+ devnull = os.open(os.devnull, os.O_WRONLY)
+ os.dup2(devnull, sys.stdout.fileno())
+ sys.exit(1)
except KeyboardInterrupt:
sys.exit(signal.SIGINT + 128)