|
|
@ -9,7 +9,7 @@ use libc::{
|
|
|
|
setuid,
|
|
|
|
setuid,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
use tokio::{
|
|
|
|
use tokio::{
|
|
|
|
runtime::{Runtime, Handle},
|
|
|
|
runtime::Runtime,
|
|
|
|
task::JoinHandle,
|
|
|
|
task::JoinHandle,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
use std::{
|
|
|
|
use std::{
|
|
|
@ -182,6 +182,7 @@ fn detach_closure_internal<F: FnOnce(Parent) -> Fu + Send + 'static, Fu: Future>
|
|
|
|
let child = unsafe{fork()};
|
|
|
|
let child = unsafe{fork()};
|
|
|
|
if child == 0 {
|
|
|
|
if child == 0 {
|
|
|
|
// Is child
|
|
|
|
// Is child
|
|
|
|
|
|
|
|
{
|
|
|
|
let _ =std::thread::spawn(move || { //Any unwind will be caught here
|
|
|
|
let _ =std::thread::spawn(move || { //Any unwind will be caught here
|
|
|
|
let mut rt = Runtime::new().unwrap_or_else(|_| std::process::exit(1)); //Immediately exit if runtime cannot be created.
|
|
|
|
let mut rt = Runtime::new().unwrap_or_else(|_| std::process::exit(1)); //Immediately exit if runtime cannot be created.
|
|
|
|
rt.block_on(async move {
|
|
|
|
rt.block_on(async move {
|
|
|
@ -221,6 +222,7 @@ fn detach_closure_internal<F: FnOnce(Parent) -> Fu + Send + 'static, Fu: Future>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}).join();
|
|
|
|
}).join();
|
|
|
|
|
|
|
|
}
|
|
|
|
std::process::exit(0);
|
|
|
|
std::process::exit(0);
|
|
|
|
} else if child > 0 {
|
|
|
|
} else if child > 0 {
|
|
|
|
// Fork succeeded
|
|
|
|
// Fork succeeded
|
|
|
|