From e4f707330c7bc39afc9cd211b731eb4af2172d9c Mon Sep 17 00:00:00 2001 From: Guillaume Chazarain Date: Sun, 26 May 2013 18:04:56 +0200 Subject: [PATCH] In some setup closing the xterm window only has the effect of deleting the pty. 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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/iotop/ui.py b/iotop/ui.py index bcc22a5..72ed7d7 100644 --- a/iotop/ui.py +++ b/iotop/ui.py @@ -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: -- 2.11.4.GIT