Rev 5155: (andrew) Reset siginterrupt flag everytime we handle a signal to in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Apr 14 12:14:33 BST 2010


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5155 [merge]
revision-id: pqm at pqm.ubuntu.com-20100414111428-ujyymfxw5zn3klcf
parent: pqm at pqm.ubuntu.com-20100414095701-ogk9ce8yrm31agm6
parent: andrew.bennetts at canonical.com-20100414064718-130ptdug4opfjj6b
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2010-04-14 12:14:28 +0100
message:
  (andrew) Reset siginterrupt flag everytime we handle a signal to
  	partially workaround http://bugs.python.org/issue8354.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/osutils.py              osutils.py-20050309040759-eeaff12fbf77ac86
=== modified file 'NEWS'
--- a/NEWS	2010-04-14 07:26:43 +0000
+++ b/NEWS	2010-04-14 11:14:28 +0000
@@ -44,6 +44,12 @@
   which is not installed any more" error.
   (Martin Pool, James Westby, #528114)
 
+* Reset ``siginterrupt`` flag to False every time we handle a signal
+  installed with ``set_signal_handler(..., restart_syscall=True)`` (from
+  ``bzrlib.osutils``.  Reduces the likelihood of "Interrupted System Call"
+  errors after two window resizes.
+  (Andrew Bennetts)
+
 * When invoked with a range revision, ``bzr log`` doesn't show revisions
   that are not part of the ancestry anymore.
   (Vincent Ladeuil, #474807)

=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py	2010-03-26 04:47:45 +0000
+++ b/bzrlib/osutils.py	2010-04-14 06:47:18 +0000
@@ -1365,15 +1365,25 @@
         False)`).  May be ignored if the feature is not available on this
         platform or Python version.
     """
-    old_handler = signal.signal(signum, handler)
+    try:
+        siginterrupt = signal.siginterrupt
+    except AttributeError:
+        # siginterrupt doesn't exist on this platform, or for this version
+        # of Python.
+        siginterrupt = lambda signum, flag: None
     if restart_syscall:
-        try:
-            siginterrupt = signal.siginterrupt
-        except AttributeError: # siginterrupt doesn't exist on this platform, or for this version of
-            # Python.
-            pass
-        else:
+        def sig_handler(*args):
+            # Python resets the siginterrupt flag when a signal is
+            # received.  <http://bugs.python.org/issue8354>
+            # As a workaround for some cases, set it back the way we want it.
             siginterrupt(signum, False)
+            # Now run the handler function passed to set_signal_handler.
+            handler(*args)
+    else:
+        sig_handler = handler
+    old_handler = signal.signal(signum, sig_handler)
+    if restart_syscall:
+        siginterrupt(signum, False)
     return old_handler
 
 




More information about the bazaar-commits mailing list