From a7e3a2dea35e912a9b3cae771c4ca2e9bcb81ab8 Mon Sep 17 00:00:00 2001 From: Andrea Righi Date: Mon, 5 Dec 2022 16:07:38 +0100 Subject: [PATCH] annotations: prevent python broken pipe errors Prevent broken pipe errors when showing output in pipe to other tools (less for example). Signed-off-by: Andrea Righi --- annotations | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/annotations b/annotations index 7138e49..a61dd3e 100755 --- a/annotations +++ b/annotations @@ -8,6 +8,7 @@ sys.dont_write_bytecode = True import argparse import json from kconfig.annotations import Annotation, KConfig +from signal import signal, SIGPIPE, SIG_DFL VERSION = '0.1' @@ -206,6 +207,11 @@ def autodetect_annotations(args): arg_fail('error: could not determine DEBDIR, try using: --file/-f') def main(): + # Prevent broken pipe errors when showing output in pipe to other tools + # (less for example) + signal(SIGPIPE, SIG_DFL) + + # Main annotations program args = _ARGPARSER.parse_args() autodetect_annotations(args) if args.value: -- 2.31.1