diff options
author | Lars Wirzenius <liw@liw.fi> | 2013-04-23 08:02:02 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2013-04-23 08:02:02 +0100 |
commit | bb8a8573c7f99e3078f0d88227ecc5d8a25456c3 (patch) | |
tree | 9a7d2c45b508094aafb701cb7cca02d2c8a4b279 | |
parent | 6f0e6c8670a4d5e2ac661342a4e42d5bd65d4fee (diff) | |
download | cliapp-bb8a8573c7f99e3078f0d88227ecc5d8a25456c3.tar.gz |
Fix cliapp.runcmd to not die from SIGWINCH
If the application is reacting to SIGWINCH, for example by using ttystatus,
it will get that signal whenever the terminal window size changes. This causes
select.select() to raise an exception, which killed the program. We now
catch the exception, check that the exception is for an interrupted system
call (EINTR), and if so, pretend as if nothing happened. Any other reasons
for the exception are re-raised.
-rw-r--r-- | cliapp/runcmd.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/cliapp/runcmd.py b/cliapp/runcmd.py index c578059..c05d5ef 100644 --- a/cliapp/runcmd.py +++ b/cliapp/runcmd.py @@ -174,7 +174,13 @@ def _run_pipeline(procs, feed_stdin, pipe_stdin, pipe_stdout, pipe_stderr): wlist.append(procs[0].stdin) if rlist or wlist: - r, w, x = select.select(rlist, wlist, []) + try: + r, w, x = select.select(rlist, wlist, []) + except select.error, e: + err, msg = e.args + if err == errno.EINTR: + break + raise else: break # Let's not busywait waiting for processes to die. |