Crate pidfile

Source
Expand description

Simple PID lock file management.

This is a very basic library for creating and using PID files to coordinate among processes.

A PID file is a file that contains the PID of a process. It can be used as a crude form of locking to prevent multiple instances of a process from running at the same time, or to provide a lock for a resource which should only be accessed by one process at a time.

This library provides a simple API for creating and using PID files. PID files are created at a given path, and are automatically removed when the PID file object is dropped.

§Example

use pidfile::PidFile;

fn main() -> Result<(), Box<dyn std::error::Error>> {
   let pidfile = PidFile::new("/tmp/myapp.pid")?;
  // Do stuff

  Ok(())
}

Structs§

PidFile
A PID file is a file that contains the PID of a process. It is used to prevent multiple instances of a process from running at the same time, or to provide a lock for a resource which should only be accessed by one process at a time.