def pid_exists(pid):
    """Check whether pid exists in the current process table."""
    if pid < 0:
        return False
    try:
        os.kill(pid, 0)
    except OSError, e:
        return e.errno == errno.EPERM
    else:
        return True
Check whether pid exists in the current process table.
recipes/Python/578022_Wait_PID_check_PID_existance/recipe-578022.py