~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Martin
  • Date: 2011-05-27 01:42:37 UTC
  • mto: (5425.4.19 220464-stale-locks)
  • mto: This revision was merged to the branch mainline in revision 5970.
  • Revision ID: gzlist@googlemail.com-20110527014237-kp0j9qua5m9fkot2
Split pid deadness detection code out into osutils

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 a process with given pid is running 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
            raise
 
2468
    else:
 
2469
        # Exists and our process: not dead.
 
2470
        return False
 
2471