Daemonize
This commit is contained in:
parent
4fbf3e4663
commit
ced0845c24
3 changed files with 20 additions and 0 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
|
@ -982,6 +982,7 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"cosmic-text 0.10.0",
|
||||
"env_logger",
|
||||
"fork",
|
||||
"i18n-embed",
|
||||
"i18n-embed-fl",
|
||||
"lazy_static",
|
||||
|
|
@ -1837,6 +1838,15 @@ version = "0.3.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b"
|
||||
|
||||
[[package]]
|
||||
name = "fork"
|
||||
version = "0.1.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf2ca97a59201425e7ee4d197c9c4fea282fe87a97d666a580bda889b95b8e88"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "form_urlencoded"
|
||||
version = "1.2.0"
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ license = "GPL-3.0-only"
|
|||
|
||||
[dependencies]
|
||||
env_logger = "0.10.0"
|
||||
fork = "0.1"
|
||||
lazy_static = "1.4.0"
|
||||
log = "0.4.20"
|
||||
notify = "6.1.1"
|
||||
|
|
|
|||
|
|
@ -60,6 +60,15 @@ lazy_static::lazy_static! {
|
|||
}
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
match fork::daemon(false, false) {
|
||||
Ok(fork::Fork::Child) => (),
|
||||
Ok(fork::Fork::Parent(_child_pid)) => process::exit(0),
|
||||
Err(err) => {
|
||||
eprintln!("failed to daemonize: {:?}", err);
|
||||
process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("warn")).init();
|
||||
|
||||
localize::localize();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue