[Git][NTPsec/ntpsec][master] ntpq: Handle BrokenPipeError

Hal Murray (@hal.murray) gitlab at mg.gitlab.com
Sat Mar 1 12:29:22 UTC 2025



Hal Murray pushed to branch master at NTPsec / ntpsec


Commits:
11d582ae by Richard Laager at 2025-02-28T22:54:39-06:00
ntpq: Handle BrokenPipeError

Closes #821

See also: https://bugs.debian.org/1092198

- - - - -


1 changed file:

- ntpclients/ntpq.py


Changes:

=====================================
ntpclients/ntpq.py
=====================================
@@ -1926,6 +1926,11 @@ if __name__ == '__main__':
                         interpreter.onecmd(interpreter.precmd(command))
                     session.close()
         raise SystemExit(0)
+    except BrokenPipeError:
+        # https://docs.python.org/3/library/signal.html#note-on-sigpipe
+        devnull = os.open(os.devnull, os.O_WRONLY)
+        os.dup2(devnull, sys.stdout.fileno())
+        raise SystemExit(1)
     except (KeyboardInterrupt, EOFError):
         if os.isatty(0):
             interpreter.say("\n")



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/11d582aececb1698131257d892b1f81a82504041

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/11d582aececb1698131257d892b1f81a82504041
You're receiving this email because of your account on gitlab.com.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20250301/2fdf47d6/attachment.htm>


More information about the vc mailing list