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.
This commit is contained in:
2017-10-11 01:04:30 -04:00
parent 04ea4aa144
commit 9d0425859b
6 changed files with 433 additions and 3 deletions

37
examples/daemon.rs Normal file
View File

@ -0,0 +1,37 @@
#[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);
}
}
}