diff --git a/crates/libcontainer/src/process/fork.rs b/crates/libcontainer/src/process/fork.rs index c0e0553969..09be4f2eea 100644 --- a/crates/libcontainer/src/process/fork.rs +++ b/crates/libcontainer/src/process/fork.rs @@ -204,9 +204,17 @@ fn clone(cb: CloneCb, flags: u64, exit_signal: Option) -> Result libc::c_int { unsafe { Box::from_raw(data as *mut CloneCb)() } } + #[cfg(test)] + extern "C" fn main(data: *mut libc::c_void) -> libc::c_int { + let mut func = unsafe { Box::from_raw(data as *mut CloneCb) }; + let ret = func(); + Box::into_raw(func); + ret + } // The nix::sched::clone wrapper doesn't provide the right interface. Using // the clone syscall is one of the rare cases where we don't want rust to