#daemon-process #daemon #process #unix #freebsd #linux

yad

Yet Another Daemonizer is a daemonizing crate to easily, simply, and correctly create legacy daemons

3 unstable releases

0.2.0 Nov 15, 2022
0.1.1 Oct 22, 2021
0.1.0 Feb 15, 2021

#867 in Unix APIs

MIT license

30KB
549 lines

Yet Another Daemonizer

Github MIT licensed Cargo Documentation

Yet Another Daemonizer is a daemonizing crate to easily, simply, and correctly create legacy daemons.

This crate focuses on manually creating a background process which is not managed by a supervisor such as systemd or launchd. It strives to follow all the best practices to correctly daemonize a process.

Example

use yad::Stdio;

match yad::with_options()
    .stdin(Stdio::Null)
    .stderr(Stdio::Null)
    .stdout(Stdio::output("/var/log/daemon.log"))
    .daemonize()
{
    Ok(_) => println!("I'm a daemon"),
    Err(err) => eprintln!("Failed to launch daemon: {}", err),
}

References

Dependencies

~2.5MB
~53K SLoC