- waitpid(pid, NULL, 0);
- /* Our convention to tell Lisp that it was the exec that
- * failed, not the fork. */
- pid = -2;
+ int status;
+ waitpid(pid, &status, 0);
+ /* Our convention to tell Lisp that it was the exec or
+ chdir that failed, not the fork. */
+ /* FIXME: there are other values waitpid(2) can return. */
+ if (WIFEXITED(status)) {
+ pid = -WEXITSTATUS(status);
+ }