Restore the default SIGPIPE handler
authorGuillaume Chazarain <guichaz@gmail.com>
Sun, 22 Jan 2012 20:36:22 +0000 (22 21:36 +0100)
committerGuillaume Chazarain <guichaz@gmail.com>
Sun, 22 Jan 2012 20:36:22 +0000 (22 21:36 +0100)
so that sudo ./iotop.py -b|head does what's expected.

iotop/ui.py

index 6c4ffa1..3292310 100644 (file)
@@ -23,6 +23,7 @@ import math
 import optparse
 import os
 import select
+import signal
 import sys
 import time
 
@@ -465,6 +466,8 @@ class IOTopUI(object):
             self.win.refresh()
 
 def run_iotop_window(win, options):
+    if options.batch:
+        signal.signal(signal.SIGPIPE, signal.SIG_DFL)
     taskstats_connection = TaskStatsNetlink(options)
     process_list = ProcessList(taskstats_connection, options)
     ui = IOTopUI(win, process_list, options)