diff options
Diffstat (limited to 'crates/runner/src/util/clone.rs')
-rw-r--r-- | crates/runner/src/util/clone.rs | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/crates/runner/src/util/clone.rs b/crates/runner/src/util/clone.rs index 4835b53..0af9e4d 100644 --- a/crates/runner/src/util/clone.rs +++ b/crates/runner/src/util/clone.rs @@ -1,6 +1,9 @@ use std::{mem, process}; -use nix::{errno, sched, unistd}; +use nix::{ + errno, sched, + unistd::{self, Pid}, +}; #[repr(C)] #[derive(Debug, Default)] @@ -30,18 +33,14 @@ pub unsafe fn clone(flags: sched::CloneFlags) -> nix::Result<unistd::ForkResult> Ok(unistd::ForkResult::Child) } else { Ok(unistd::ForkResult::Parent { - child: unistd::Pid::from_raw(pid as libc::pid_t), + child: Pid::from_raw(pid as libc::pid_t), }) } } -pub unsafe fn spawn<T, F>( - flags: Option<sched::CloneFlags>, - arg: T, - f: F, -) -> nix::Result<(unistd::Pid, T)> +pub unsafe fn spawn<F>(flags: Option<sched::CloneFlags>, f: F) -> nix::Result<Pid> where - F: FnOnce(T), + F: FnOnce(), { let res = if let Some(flags) = flags { clone(flags) @@ -49,9 +48,9 @@ where unistd::fork() }; match res? { - unistd::ForkResult::Parent { child } => Ok((child, arg)), + unistd::ForkResult::Parent { child } => Ok(child), unistd::ForkResult::Child => { - f(arg); + f(); process::exit(0) } } |