diff --git a/src/bin/izoli.rs b/src/bin/izoli.rs index 5103fc3..2f57ed4 100644 --- a/src/bin/izoli.rs +++ b/src/bin/izoli.rs @@ -40,9 +40,6 @@ fn main() { let pid = izolibox .enter(Box::new(|| { - IzoliBox::prelude(1).unwrap(); - println!("Isolated process: {}", std::process::id()); - let cmd = CString::new("/usr/bin/bash").unwrap(); let args: Vec = vec![]; if let Err(e) = execvp(&cmd, &args.as_ref()) { diff --git a/src/izolibox.rs b/src/izolibox.rs index c94e3af..2b8a601 100644 --- a/src/izolibox.rs +++ b/src/izolibox.rs @@ -46,7 +46,16 @@ impl IzoliBox { cgroup.enter().unwrap(); } - unsafe { sched::clone(callback, &mut stack, flags, Some(SIGCHLD)) } + let mut callback = callback; + let new_callback = Box::new(|| { + IzoliBox::prelude(self.id).unwrap(); + + callback(); + + 127 + }); + + unsafe { sched::clone(new_callback, &mut stack, flags, Some(SIGCHLD)) } } pub fn prelude(id: usize) -> Result<(), Box> {