From eebf12bec5c0999adf9d898a7a78b9fc3d2367ca Mon Sep 17 00:00:00 2001 From: Jeremy Soller <jackpot51@gmail.com> Date: Sun, 29 Oct 2017 15:41:59 -0600 Subject: [PATCH] Fix returning too many errors from waitpid --- src/syscall/process.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/syscall/process.rs b/src/syscall/process.rs index 98e30344..d396be20 100644 --- a/src/syscall/process.rs +++ b/src/syscall/process.rs @@ -1160,17 +1160,20 @@ pub fn waitpid(pid: ContextId, status_ptr: usize, flags: usize) -> Result<Contex } else { let status = { let contexts = context::contexts(); - let context_lock = contexts.get(pid).ok_or(Error::new(ECHILD))?; - let mut context = context_lock.write(); - if context.ppid != ppid { - println!("Hack for rustc - changing ppid of {} from {} to {}", context.id.into(), context.ppid.into(), ppid.into()); - context.ppid = ppid; - //return Err(Error::new(ECHILD)); + if let Some(context_lock) = contexts.get(pid) { + let mut context = context_lock.write(); + if context.ppid != ppid { + println!("Hack for rustc - changing ppid of {} from {} to {}", context.id.into(), context.ppid.into(), ppid.into()); + context.ppid = ppid; + //return Err(Error::new(ECHILD)); + } + Some(context.status.clone()) + } else { + None } - context.status.clone() }; - if let context::Status::Exited(status) = status { + if let Some(context::Status::Exited(status)) = status { status_slice[0] = status; reap(pid) } else if flags & WNOHANG == WNOHANG { -- GitLab