changeset 30654:5f33116cd787 stable

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.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 22 Dec 2016 23:14:13 +0900
parents 1914db1b7d9e
children e69874dc1f4e
files mercurial/posix.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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, []))))