Fix daemonization
This commit is contained in:
parent
096aedc0d4
commit
e72a16a5bd
1 changed files with 7 additions and 1 deletions
|
@ -181,7 +181,13 @@ pub enum ForkResult {
|
|||
fn do_detach(log_file_path: impl AsRef<Path>) -> Result<ForkResult> {
|
||||
// detach from terminal
|
||||
match unsafe { nix::unistd::fork()? } {
|
||||
nix::unistd::ForkResult::Child => {}
|
||||
nix::unistd::ForkResult::Child => {
|
||||
nix::unistd::setsid()?;
|
||||
match unsafe {nix::unistd::fork()?
|
||||
}{
|
||||
nix::unistd::ForkResult::Parent { .. } => std::process::exit(0),
|
||||
nix::unistd::ForkResult::Child => {}
|
||||
}}
|
||||
nix::unistd::ForkResult::Parent { .. } => {
|
||||
return Ok(ForkResult::Parent);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue