Skip to content

Commit

Permalink
Handle broken pipes in arc_summary
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dinatale2 authored and behlendorf committed Dec 19, 2017
1 parent c4ba46d commit 89a66a0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/arc_summary/arc_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import os
import sys
import time
import errno

from subprocess import Popen, PIPE
from decimal import Decimal as D
Expand All @@ -55,6 +56,18 @@
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ while [[ $i -lt ${#args[*]} ]]; do
((i = i + 1))
done

log_must eval "arc_summary.py | head > /dev/null"
log_must eval "arc_summary.py | head -1 > /dev/null"

log_pass "arc_summary.py generates output and doesn't return an error code"

0 comments on commit 89a66a0

Please sign in to comment.