~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-06-14 08:08:36 UTC
  • mfrom: (5425.4.30 220464-stale-locks)
  • Revision ID: pqm@pqm.ubuntu.com-20110614080836-d06kod1br6j1rx6j
(mbp) optionally detect and steal dead locks from the same machine and user
 (bug 220464) (Martin Pool)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2448
2448
            if os.access(f, os.X_OK):
2449
2449
                return f
2450
2450
    return None
 
2451
 
 
2452
 
 
2453
def _posix_is_local_pid_dead(pid):
 
2454
    """True if pid doesn't correspond to live process on this machine"""
 
2455
    try:
 
2456
        # Special meaning of unix kill: just check if it's there.
 
2457
        os.kill(pid, 0)
 
2458
    except OSError, e:
 
2459
        if e.errno == errno.ESRCH:
 
2460
            # On this machine, and really not found: as sure as we can be
 
2461
            # that it's dead.
 
2462
            return True
 
2463
        elif e.errno == errno.EPERM:
 
2464
            # exists, though not ours
 
2465
            return False
 
2466
        else:
 
2467
            mutter("os.kill(%d, 0) failed: %s" % (pid, e))
 
2468
            # Don't really know.
 
2469
            return False
 
2470
    else:
 
2471
        # Exists and our process: not dead.
 
2472
        return False
 
2473
 
 
2474
if sys.platform == "win32":
 
2475
    is_local_pid_dead = win32utils.is_local_pid_dead
 
2476
else:
 
2477
    is_local_pid_dead = _posix_is_local_pid_dead