diff options
author | Giuseppe Di Natale <[email protected]> | 2017-12-19 13:19:24 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2017-12-19 13:19:24 -0800 |
commit | 89a66a0457cd392ab8c6ad6d9c138fedaa425067 (patch) | |
tree | 98e8780818ed2e25a5009941235a9eaf367d355c /cmd/arc_summary/arc_summary.py | |
parent | c4ba46deade0a14d089228a56a5d0aa0ffd5fadd (diff) |
Handle broken pipes in arc_summary
Using a command similar to 'arc_summary.py | head' causes
a broken pipe exception. Gracefully exit in the case of a
broken pipe in arc_summary.py.
Reviewed-by: Richard Elling <[email protected]>
Reviewed-by: loli10K <[email protected]>
Signed-off-by: Giuseppe Di Natale <[email protected]>
Closes #6965
Closes #6969
Diffstat (limited to 'cmd/arc_summary/arc_summary.py')
-rwxr-xr-x | cmd/arc_summary/arc_summary.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/cmd/arc_summary/arc_summary.py b/cmd/arc_summary/arc_summary.py index 2472f87ea..f6dbb9bfb 100755 --- a/cmd/arc_summary/arc_summary.py +++ b/cmd/arc_summary/arc_summary.py @@ -47,6 +47,7 @@ import getopt import os import sys import time +import errno from subprocess import Popen, PIPE from decimal import Decimal as D @@ -55,6 +56,18 @@ show_tunable_descriptions = False alternate_tunable_layout = False +def handle_Exception(ex_cls, ex, tb): + if ex is IOError: + if ex.errno == errno.EPIPE: + sys.exit() + + if ex is KeyboardInterrupt: + sys.exit() + + +sys.excepthook = handle_Exception + + def get_Kstat(): """Collect information on the ZFS subsystem from the /proc virtual file system. The name "kstat" is a holdover from the Solaris utility |