diff --git a/src/code/run-program.lisp b/src/code/run-program.lisp index f16dfb08865f9897facf8ab2c6a0ffc54d4d33cd..5a7f6e1e0de3a53292975571821a21c7156376ef 100644 --- a/src/code/run-program.lisp +++ b/src/code/run-program.lisp @@ -85,7 +85,7 @@ (declare (ignore ret)) (when (plusp pid) (values pid - (aref #(nil :signaled :stopped :continued :exited) what) + (aref #(:signaled :stopped :continued :exited) what) code (not (zerop corep)))))) @@ -217,7 +217,8 @@ (declare (type process proc)) (let ((status (process-status proc))) (if (or (eq status :running) - (eq status :stopped)) + (eq status :stopped) + (eq status :continued)) t nil))) diff --git a/src/lisp/runprog.c b/src/lisp/runprog.c index e6a5a0d77ef248c33c8043c2b5538b9278a6ef7b..852584a83eb881134419bcc746902a87ea45ca04 100644 --- a/src/lisp/runprog.c +++ b/src/lisp/runprog.c @@ -3,6 +3,8 @@ * */ +#include <stdio.h> + #include <sys/ioctl.h> #include <errno.h> #include <fcntl.h> @@ -85,6 +87,17 @@ spawn(char *program, char *argv[], char *envp[], char *pty_name, * core - true (non-zero) if a core was produced */ +/* + * Status codes. Must be in the same order as in ext::prog-status in + * run-program.lisp + */ +enum status_code { + SIGNALED, + STOPPED, + CONTINUED, + EXITED +}; + void prog_status(pid_t* pid, int* what, int* code, int* corep) { @@ -100,21 +113,23 @@ prog_status(pid_t* pid, int* what, int* code, int* corep) } if (WIFEXITED(status)) { - *what = 4; + *what = EXITED; *code = WEXITSTATUS(status); *corep = 0; } else if (WIFSIGNALED(status)) { - *what = 1; + *what = SIGNALED; *code = WTERMSIG(status); *corep = WCOREDUMP(status); } else if (WIFSTOPPED(status)) { - *what = 2; + *what = STOPPED; *code = WSTOPSIG(status); *corep = 0; } else if (WIFCONTINUED(status)) { - *what = 3; + *what = CONTINUED; *code = 0; *corep = 0; + } else { + fprintf(stderr, "pid = %d, status = 0x%x\n", *pid, status); } return;