Commit 65ce358d authored by Raymond Toy's avatar Raymond Toy

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
Pipeline #173 passed with stage
in 9 minutes and 36 seconds
......@@ -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)))
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment