#include <fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>
-
+#include <sys/wait.h>
#include <sys/ioctl.h>
#include <termios.h>
#include <errno.h>
p += n;
}
}
+ close(channel[0]);
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;
}
}
if (fd != channel[1]) close(fd);
#endif
- environ = envp;
+ if (envp) {
+ environ = envp;
+ }
/* Exec the program. */
if (search)
execvp(program, argv);