From 5e58b05a93cefa55763000e29244f4e8ddea6c69 Mon Sep 17 00:00:00 2001 From: Noah <33094578+coolreader18@users.noreply.github.com> Date: Wed, 8 Apr 2020 12:08:01 -0500 Subject: [PATCH] Fix subprocess.call --- vm/src/stdlib/subprocess.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/vm/src/stdlib/subprocess.rs b/vm/src/stdlib/subprocess.rs index 10b618547..67cffccb3 100644 --- a/vm/src/stdlib/subprocess.rs +++ b/vm/src/stdlib/subprocess.rs @@ -148,7 +148,7 @@ impl PopenRef { self.process.borrow().exit_status() } - fn wait(self, args: PopenWaitArgs, vm: &VirtualMachine) -> PyResult<()> { + fn wait(self, args: PopenWaitArgs, vm: &VirtualMachine) -> PyResult { let timeout = match args.timeout { Some(timeout) => self .process @@ -157,11 +157,16 @@ impl PopenRef { None => self.process.borrow_mut().wait().map(Some), } .map_err(|s| vm.new_os_error(format!("Could not start program: {}", s)))?; - if timeout.is_none() { + if let Some(exit) = timeout { + use subprocess::ExitStatus::*; + Ok(match exit { + Exited(i) => i.into(), + Signaled(s) => -i64::from(s), + _ => unreachable!("should not occur in normal operation"), + }) + } else { let timeout_expired = vm.try_class("_subprocess", "TimeoutExpired")?; Err(vm.new_exception_msg(timeout_expired, "Timeout".to_owned())) - } else { - Ok(()) } }