In some setup closing the xterm window only has the effect of deleting the pty.
authorGuillaume Chazarain <guichaz@gmail.com>
Sun, 26 May 2013 16:04:56 +0000 (26 18:04 +0200)
committerGuillaume Chazarain <guichaz@gmail.com>
Sun, 26 May 2013 16:05:39 +0000 (26 18:05 +0200)
Then iotop would be busy looping reading on stdin. Instead we should detect the
terminal deletion and exit.
When this happens iotop receives (0, 25) as an event, which is
(stdin, select.POLLIN|select.POLLERR|select.POLLHUP).

Also, represent an empty even list as [] instead of 0, this is just cosmetic.

iotop/ui.py

index bcc22a5..72ed7d7 100644 (file)
@@ -164,9 +164,12 @@ class IOTopUI(object):
                 events = poll.poll(self.options.delay_seconds * 1000.0)
             except select.error as e:
                 if e.args and e.args[0] == errno.EINTR:
-                    events = 0
+                    events = []
                 else:
                     raise
+            for (fd, event) in events:
+                if event & (select.POLLERR | select.POLLHUP):
+                    sys.exit(1)
             if not self.options.batch:
                 self.resize()
             if events: