posix: make poll() restart on interruption by signal (issue5452) stable
authorYuya Nishihara <yuya@tcha.org>
Thu, 22 Dec 2016 23:14:13 +0900
branchstable
changeset 30654 5f33116cd787
parent 30647 1914db1b7d9e
child 30682 e69874dc1f4e
posix: make poll() restart on interruption by signal (issue5452) select() is a notable example of syscalls which may fail with EINTR. If we had a SIGWINCH handler installed, ssh would crash when the terminal window was resized. This patch fixes the problem.
mercurial/posix.py
--- a/mercurial/posix.py	Mon Dec 19 22:46:00 2016 +0900
+++ b/mercurial/posix.py	Thu Dec 22 23:14:13 2016 +0900
@@ -570,7 +570,14 @@
 
     In unsupported cases, it will raise a NotImplementedError"""
     try:
-        res = select.select(fds, fds, fds)
+        while True:
+            try:
+                res = select.select(fds, fds, fds)
+                break
+            except select.error as inst:
+                if inst.args[0] == errno.EINTR:
+                    continue
+                raise
     except ValueError: # out of range file descriptor
         raise NotImplementedError()
     return sorted(list(set(sum(res, []))))