def get_pid_from_file(pidfile_path):
    """Retrieve the PID from the given file, if it exists, None otherwise."""
    try:
        with open(pidfile_path, 'r') as fd:
            pid = fd.read().split()[0]
    except IOError:
        return None
    try:
        pid = int(pid)
    except ValueError:
        return None
    return pid
