Raymond Toy pushed to branch rtoy-fix-issue-41 at cmucl / cmucl Commits: 65ce358d by Raymond Toy at 2017-09-15T22:50:47-07:00 Fix up minor issues in implementation - process-alive-p should return T for continued processes - Simplify prog-status slightly by making the status code array start :signaled instead of nil. - Update prog_status with enum to specify the codes to make it clearer what they mean and to make it clearer that it matches the expectations in prog-status. - - - - - 2 changed files: - src/code/run-program.lisp - src/lisp/runprog.c Changes: ===================================== src/code/run-program.lisp ===================================== --- 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))) ===================================== src/lisp/runprog.c ===================================== --- 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; View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/commit/65ce358d918559662672cb1ae7... --- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/commit/65ce358d918559662672cb1ae7... You're receiving this email because of your account on gitlab.common-lisp.net.