daemon/examples/daemon.rs
Jason Travis Smith 9d0425859b A Daemon can now be created using the Daemon::spawn function.
This follows the POSIX standard way of creating a daemon process.
This does not use the systemd or other init system specifics.
2017-10-11 01:04:30 -04:00

38 lines
535 B
Rust

#[macro_use]
extern crate scribe;
extern crate weave;
extern crate daemon;
use weave::{ExitCode, Terminate};
use daemon::Daemon;
fn child_entry(pid: i64) -> Box<Terminate>
{
println!("Child ending. ID: {}", pid);
Box::new(ExitCode::GeneralFailure)
}
fn main()
{
println!("Starting Daemon example.");
match Daemon::spawn(&child_entry)
{
Ok(exit_code) =>
{
println!("Exiting with: {}", exit_code.get_code());
}
Err(error) =>
{
error!("{}", error);
}
}
}