auto prelude

This commit is contained in:
mii
2024-10-31 13:45:02 +09:00
parent 2245d7c088
commit 6f49c5af3b
2 changed files with 10 additions and 4 deletions

View File

@ -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<CString> = vec![];
if let Err(e) = execvp(&cmd, &args.as_ref()) {

View File

@ -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<dyn std::error::Error>> {