~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Andrew Bennetts
  • Date: 2010-03-11 04:33:41 UTC
  • mfrom: (4797.33.4 2.1)
  • mto: This revision was merged to the branch mainline in revision 5082.
  • Revision ID: andrew.bennetts@canonical.com-20100311043341-rzdik83fnactjsxs
Merge lp:bzr/2.1, including fixes for #496813, #526211, #526353.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1349
1349
    normalized_filename = _inaccessible_normalized_filename
1350
1350
 
1351
1351
 
 
1352
def set_signal_handler(signum, handler, restart_syscall=True):
 
1353
    """A wrapper for signal.signal that also calls siginterrupt(signum, False)
 
1354
    on platforms that support that.
 
1355
 
 
1356
    :param restart_syscall: if set, allow syscalls interrupted by a signal to
 
1357
        automatically restart (by calling `signal.siginterrupt(signum,
 
1358
        False)`).  May be ignored if the feature is not available on this
 
1359
        platform or Python version.
 
1360
    """
 
1361
    old_handler = signal.signal(signum, handler)
 
1362
    if restart_syscall:
 
1363
        try:
 
1364
            siginterrupt = signal.siginterrupt
 
1365
        except AttributeError: # siginterrupt doesn't exist on this platform, or for this version of
 
1366
            # Python.
 
1367
            pass
 
1368
        else:
 
1369
            siginterrupt(signum, False)
 
1370
    return old_handler
 
1371
 
 
1372
 
1352
1373
default_terminal_width = 80
1353
1374
"""The default terminal width for ttys.
1354
1375
 
1456
1477
            # the current design -- vila 20091216
1457
1478
            pass
1458
1479
        else:
1459
 
            signal.signal(signal.SIGWINCH, _terminal_size_changed)
 
1480
            set_signal_handler(signal.SIGWINCH, _terminal_size_changed)
1460
1481
        _registered_sigwinch = True
1461
1482
 
1462
1483