use SIGTERM for os/proc-kill signal test

This commit is contained in:
tionis 2023-05-16 18:47:38 +02:00
parent 56d72ec4c5
commit 0f35acade1
2 changed files with 6 additions and 4 deletions

View File

@ -629,7 +629,9 @@ struct keyword_signal {
int signal;
};
static const struct keyword_signal signal_keywords[] = {
#ifdef SIGKILL
{"kill", SIGKILL},
#endif
{"int", SIGINT},
{"abrt", SIGABRT},
{"fpe", SIGFPE},
@ -716,9 +718,8 @@ JANET_CORE_FN(os_proc_kill,
if (proc->flags & JANET_PROC_WAITED) {
janet_panicf("cannot kill process that has already finished");
}
int signal = SIGKILL;
int signal = -1;
if(argc == 3){
int signal = -1;
JanetKeyword signal_kw = janet_getkeyword(argv, 2);
const struct keyword_signal *ptr = signal_keywords;
while (ptr->keyword){
@ -737,7 +738,7 @@ JANET_CORE_FN(os_proc_kill,
janet_panicf("cannot close process handle that is already closed");
}
proc->flags |= JANET_PROC_CLOSED;
if(signal == SIGKILL){
if(signal == -1){
TerminateProcess(proc->pHandle, 1);
}else{
int status = kill(proc->pid, signal);
@ -748,6 +749,7 @@ JANET_CORE_FN(os_proc_kill,
CloseHandle(proc->pHandle);
CloseHandle(proc->tHandle);
#else
if(signal == -1){signal=SIGKILL;}
int status = kill(proc->pid, signal);
if (status) {
janet_panic(strerror(errno));

View File

@ -53,7 +53,7 @@
(assert (not= retval 24) "Process was *not* terminated by parent"))
(let [p (os/spawn [janet "-e" `(do (ev/sleep 30) (os/exit 24)`] :p)]
(os/proc-kill p false :kill)
(os/proc-kill p false :term)
(def retval (os/proc-wait p))
(assert (not= retval 24) "Process was *not* terminated by parent"))