Further work towards use of win32 file HANDLEs
[sbcl.git] / src / runtime / run-program.c
index 4e6f829..367dd77 100644 (file)
@@ -25,7 +25,7 @@
 #include <fcntl.h>
 #include <sys/ioctl.h>
 #include <unistd.h>
-
+#include <sys/wait.h>
 #include <sys/ioctl.h>
 #include <termios.h>
 #include <errno.h>
@@ -138,6 +138,7 @@ int spawn(char *program, char *argv[], int sin, int sout, int serr,
                     p += n;
                 }
             }
+            close(channel[0]);
             if (child_errno) {
                 waitpid(pid, NULL, 0);
                 /* Our convention to tell Lisp that it was the exec that
@@ -192,7 +193,9 @@ int spawn(char *program, char *argv[], int sin, int sout, int serr,
         if (fd != channel[1]) close(fd);
 #endif
 
-    environ = envp;
+    if (envp) {
+      environ = envp;
+    }
     /* Exec the program. */
     if (search)
       execvp(program, argv);