Skip to content
Snippets Groups Projects
Commit 65ce358d authored by Raymond Toy's avatar Raymond Toy
Browse files

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.
parent f05cb10a
No related branches found
No related tags found
No related merge requests found
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
(declare (ignore ret)) (declare (ignore ret))
(when (plusp pid) (when (plusp pid)
(values pid (values pid
(aref #(nil :signaled :stopped :continued :exited) what) (aref #(:signaled :stopped :continued :exited) what)
code code
(not (zerop corep)))))) (not (zerop corep))))))
...@@ -217,7 +217,8 @@ ...@@ -217,7 +217,8 @@
(declare (type process proc)) (declare (type process proc))
(let ((status (process-status proc))) (let ((status (process-status proc)))
(if (or (eq status :running) (if (or (eq status :running)
(eq status :stopped)) (eq status :stopped)
(eq status :continued))
t t
nil))) nil)))
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
* *
*/ */
#include <stdio.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
...@@ -85,6 +87,17 @@ spawn(char *program, char *argv[], char *envp[], char *pty_name, ...@@ -85,6 +87,17 @@ spawn(char *program, char *argv[], char *envp[], char *pty_name,
* core - true (non-zero) if a core was produced * 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 void
prog_status(pid_t* pid, int* what, int* code, int* corep) 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) ...@@ -100,21 +113,23 @@ prog_status(pid_t* pid, int* what, int* code, int* corep)
} }
if (WIFEXITED(status)) { if (WIFEXITED(status)) {
*what = 4; *what = EXITED;
*code = WEXITSTATUS(status); *code = WEXITSTATUS(status);
*corep = 0; *corep = 0;
} else if (WIFSIGNALED(status)) { } else if (WIFSIGNALED(status)) {
*what = 1; *what = SIGNALED;
*code = WTERMSIG(status); *code = WTERMSIG(status);
*corep = WCOREDUMP(status); *corep = WCOREDUMP(status);
} else if (WIFSTOPPED(status)) { } else if (WIFSTOPPED(status)) {
*what = 2; *what = STOPPED;
*code = WSTOPSIG(status); *code = WSTOPSIG(status);
*corep = 0; *corep = 0;
} else if (WIFCONTINUED(status)) { } else if (WIFCONTINUED(status)) {
*what = 3; *what = CONTINUED;
*code = 0; *code = 0;
*corep = 0; *corep = 0;
} else {
fprintf(stderr, "pid = %d, status = 0x%x\n", *pid, status);
} }
return; return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment