From: Nikodemus Siivola Date: Sun, 20 Nov 2011 11:54:07 +0000 (+0200) Subject: fix RUN-PROGRAM :WAIT T on Windows X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=7e0235c6f230d9e07a710a33479697f174f393fb;p=sbcl.git fix RUN-PROGRAM :WAIT T on Windows Recent change to report the errno from exec() broke things on Windows. There when :WAIT is true it is the C code that waits, and the subsequently returns the exit code of the process -- meaning our attempt to use 0 to indicate exec() failure makes every successfull execution on Windows look like an exec failure. Oops. Use -2 instead. MORE MAGIC. --- diff --git a/src/code/run-program.lisp b/src/code/run-program.lisp index b4394a1..b854e31 100644 --- a/src/code/run-program.lisp +++ b/src/code/run-program.lisp @@ -773,7 +773,7 @@ Users Manual for details about the PROCESS structure."#-win32" (if search 1 0) environment-vec pty-name (if wait 1 0)))) - (when (plusp child) + (unless (minusp child) (setf proc (apply #'make-process @@ -791,9 +791,13 @@ Users Manual for details about the PROCESS structure."#-win32" (list :%status :running)))) (push proc *active-processes*))))) ;; Report the error outside the lock. + #+win32 + (when (minusp child) + (error "Couldn't execute ~S: ~A" progname (strerror))) + #-win32 (case child - (0 - (error "Couldn't execute ~A: ~A" progname (strerror))) + (-2 + (error "Couldn't execute ~S: ~A" progname (strerror))) (-1 (error "Couldn't fork child process: ~A" (strerror)))))))))) (dolist (fd *close-in-parent*) diff --git a/src/runtime/run-program.c b/src/runtime/run-program.c index 7377e7f..4e6f829 100644 --- a/src/runtime/run-program.c +++ b/src/runtime/run-program.c @@ -140,7 +140,9 @@ int spawn(char *program, char *argv[], int sin, int sout, int serr, } if (child_errno) { waitpid(pid, NULL, 0); - pid = 0; + /* Our convention to tell Lisp that it was the exec that + * failed, not the fork. */ + pid = -2; errno = child_errno; } }