/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Martin Pool
  • Date: 2010-04-16 07:56:51 UTC
  • mfrom: (5160 +trunk)
  • mto: (5050.3.4 2.2)
  • mto: This revision was merged to the branch mainline in revision 5173.
  • Revision ID: mbp@sourcefrog.net-20100416075651-bf23hr9hlof64gpj
merge trunk to 2.2 preparing for 2.2b2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1365
1365
        False)`).  May be ignored if the feature is not available on this
1366
1366
        platform or Python version.
1367
1367
    """
1368
 
    old_handler = signal.signal(signum, handler)
 
1368
    try:
 
1369
        siginterrupt = signal.siginterrupt
 
1370
    except AttributeError:
 
1371
        # siginterrupt doesn't exist on this platform, or for this version
 
1372
        # of Python.
 
1373
        siginterrupt = lambda signum, flag: None
1369
1374
    if restart_syscall:
1370
 
        try:
1371
 
            siginterrupt = signal.siginterrupt
1372
 
        except AttributeError: # siginterrupt doesn't exist on this platform, or for this version of
1373
 
            # Python.
1374
 
            pass
1375
 
        else:
 
1375
        def sig_handler(*args):
 
1376
            # Python resets the siginterrupt flag when a signal is
 
1377
            # received.  <http://bugs.python.org/issue8354>
 
1378
            # As a workaround for some cases, set it back the way we want it.
1376
1379
            siginterrupt(signum, False)
 
1380
            # Now run the handler function passed to set_signal_handler.
 
1381
            handler(*args)
 
1382
    else:
 
1383
        sig_handler = handler
 
1384
    old_handler = signal.signal(signum, sig_handler)
 
1385
    if restart_syscall:
 
1386
        siginterrupt(signum, False)
1377
1387
    return old_handler
1378
1388
 
1379
1389