|
|
|
@ -9,7 +9,7 @@ use libc::{
|
|
|
|
|
setuid,
|
|
|
|
|
};
|
|
|
|
|
use tokio::{
|
|
|
|
|
runtime::{Runtime, Handle},
|
|
|
|
|
runtime::Runtime,
|
|
|
|
|
task::JoinHandle,
|
|
|
|
|
};
|
|
|
|
|
use std::{
|
|
|
|
@ -182,6 +182,7 @@ fn detach_closure_internal<F: FnOnce(Parent) -> Fu + Send + 'static, Fu: Future>
|
|
|
|
|
let child = unsafe{fork()};
|
|
|
|
|
if child == 0 {
|
|
|
|
|
// Is child
|
|
|
|
|
{
|
|
|
|
|
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.
|
|
|
|
|
rt.block_on(async move {
|
|
|
|
@ -221,6 +222,7 @@ fn detach_closure_internal<F: FnOnce(Parent) -> Fu + Send + 'static, Fu: Future>
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}).join();
|
|
|
|
|
}
|
|
|
|
|
std::process::exit(0);
|
|
|
|
|
} else if child > 0 {
|
|
|
|
|
// Fork succeeded
|
|
|
|
|