diff --git a/scripts/log-search b/scripts/log-search index 75bf63a8ae..26026bb46d 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)