fix the problem when subprcess clone again

This commit is contained in:
guochao 2023-11-03 10:09:56 +08:00
parent 56dd40cd1c
commit e1ba2f7141

View File

@ -74,7 +74,9 @@ fn main() -> anyhow::Result<()> {
loop {
log::debug!("parent: waitpid...");
match waitpid(child, None)? {
let waitstatus = waitpid(child, None)?;
match waitstatus {
WaitStatus::Exited(pid, ret) => {
log::info!("child {pid} exited with return code {ret}");
break;
@ -96,7 +98,9 @@ fn main() -> anyhow::Result<()> {
}
_ => {}
}
nix::sys::ptrace::cont(child, None)?;
if let Some(pid) = waitstatus.pid() {
nix::sys::ptrace::cont(pid, None)?;
}
}
return Ok(());
}
@ -171,4 +175,3 @@ fn main() -> anyhow::Result<()> {
panic!("unreachable");
}