pub fn get_owner(&self) -> Result<Option<u32>, PidFileError> {
        let mut file = match fs::OpenOptions::new().read(true).open(self.path.clone()) {
            Ok(file) => file,
            Err(io_err) => {
                // If the file doesn't exist, there's no owner. If, on the
                // other hand, some other IO error occurred, we don't know
                // the situation and need to return an error
                if io_err.kind() == io::ErrorKind::NotFound {
                    return Ok(None);
                } else {
                    return Err(PidFileError::IO(io_err, self.path.display().to_string()));
                }
            }
        };

        let mut contents = String::new();
        if let Err(io_err) = file.read_to_string(&mut contents) {
            warn!("corrupted/invalid pid file at {:?}: {}", self.path, io_err);
            // Return an error, because None implies that we would succeed at
            // creating a pid file, but we won't. We require the file to not
            // exist if we're going to create it.
            // TODO: should we instead try deleting the file like with stale pids?
            return Err(PidFileError::IO(io_err, self.path.display().to_string()));
        }

        match contents.trim().parse::<i32>() {
            Ok(pid) if process_exists(pid) => {
                let pid: u32 =
                    pid.try_into()
                        .map_err(|e: TryFromIntError| PidFileError::Invalid {
                            error: e.to_string(),
                            contents,
                            file: self.path.display().to_string(),
                        })?;
                Ok(Some(pid))
            }
            Ok(_) => {
                warn!("stale pid file at {:?}", self.path);
                if let Err(e) = fs::remove_file(&self.path) {
                    Err(PidFileError::FailedDelete(
                        e,
                        self.path.display().to_string(),
                    ))
                } else {
                    Ok(None)
                }
            }
            Err(e) => Err(PidFileError::Invalid {
                error: e.to_string(),
                contents,
                file: self.path.display().to_string(),
            }),
        }
    }
Gets the owner of this lockfile, returning the pid. If the lock file
doesn't exist, or the specified pid is not a valid process id on the
system, it clears it.
crates/turborepo-pidlock/src/lib.rs