From 0973bccfe2bf1140021a3f670974bf073bfb5eac Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Tue, 20 Mar 2012 12:38:57 -0700 Subject: [PATCH] Fail when there's an error starting a process. Close #1778. --- src/libcore/run.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libcore/run.rs b/src/libcore/run.rs index 58354bc49ca..693832fca9d 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -161,8 +161,10 @@ Spawns a process and waits for it to terminate The process id "] fn run_program(prog: str, args: [str]) -> int { - ret waitpid(spawn_process(prog, args, none, none, - 0i32, 0i32, 0i32)); + let pid = spawn_process(prog, args, none, none, + 0i32, 0i32, 0i32); + if pid == -1 as pid_t { fail; } + ret waitpid(pid); } #[doc =" @@ -190,7 +192,7 @@ fn start_program(prog: str, args: [str]) -> program { pipe_input.in, pipe_output.out, pipe_err.out); - if pid == -1i32 { fail; } + if pid == -1 as pid_t { fail; } libc::close(pipe_input.in); libc::close(pipe_output.out); libc::close(pipe_err.out);