mirror of
https://github.com/janet-lang/janet
synced 2025-01-12 16:40:27 +00:00
use SIGTERM for os/proc-kill signal test
This commit is contained in:
parent
56d72ec4c5
commit
0f35acade1
@ -629,7 +629,9 @@ struct keyword_signal {
|
|||||||
int signal;
|
int signal;
|
||||||
};
|
};
|
||||||
static const struct keyword_signal signal_keywords[] = {
|
static const struct keyword_signal signal_keywords[] = {
|
||||||
|
#ifdef SIGKILL
|
||||||
{"kill", SIGKILL},
|
{"kill", SIGKILL},
|
||||||
|
#endif
|
||||||
{"int", SIGINT},
|
{"int", SIGINT},
|
||||||
{"abrt", SIGABRT},
|
{"abrt", SIGABRT},
|
||||||
{"fpe", SIGFPE},
|
{"fpe", SIGFPE},
|
||||||
@ -716,9 +718,8 @@ JANET_CORE_FN(os_proc_kill,
|
|||||||
if (proc->flags & JANET_PROC_WAITED) {
|
if (proc->flags & JANET_PROC_WAITED) {
|
||||||
janet_panicf("cannot kill process that has already finished");
|
janet_panicf("cannot kill process that has already finished");
|
||||||
}
|
}
|
||||||
int signal = SIGKILL;
|
int signal = -1;
|
||||||
if(argc == 3){
|
if(argc == 3){
|
||||||
int signal = -1;
|
|
||||||
JanetKeyword signal_kw = janet_getkeyword(argv, 2);
|
JanetKeyword signal_kw = janet_getkeyword(argv, 2);
|
||||||
const struct keyword_signal *ptr = signal_keywords;
|
const struct keyword_signal *ptr = signal_keywords;
|
||||||
while (ptr->keyword){
|
while (ptr->keyword){
|
||||||
@ -737,7 +738,7 @@ JANET_CORE_FN(os_proc_kill,
|
|||||||
janet_panicf("cannot close process handle that is already closed");
|
janet_panicf("cannot close process handle that is already closed");
|
||||||
}
|
}
|
||||||
proc->flags |= JANET_PROC_CLOSED;
|
proc->flags |= JANET_PROC_CLOSED;
|
||||||
if(signal == SIGKILL){
|
if(signal == -1){
|
||||||
TerminateProcess(proc->pHandle, 1);
|
TerminateProcess(proc->pHandle, 1);
|
||||||
}else{
|
}else{
|
||||||
int status = kill(proc->pid, signal);
|
int status = kill(proc->pid, signal);
|
||||||
@ -748,6 +749,7 @@ JANET_CORE_FN(os_proc_kill,
|
|||||||
CloseHandle(proc->pHandle);
|
CloseHandle(proc->pHandle);
|
||||||
CloseHandle(proc->tHandle);
|
CloseHandle(proc->tHandle);
|
||||||
#else
|
#else
|
||||||
|
if(signal == -1){signal=SIGKILL;}
|
||||||
int status = kill(proc->pid, signal);
|
int status = kill(proc->pid, signal);
|
||||||
if (status) {
|
if (status) {
|
||||||
janet_panic(strerror(errno));
|
janet_panic(strerror(errno));
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
(assert (not= retval 24) "Process was *not* terminated by parent"))
|
(assert (not= retval 24) "Process was *not* terminated by parent"))
|
||||||
|
|
||||||
(let [p (os/spawn [janet "-e" `(do (ev/sleep 30) (os/exit 24)`] :p)]
|
(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))
|
(def retval (os/proc-wait p))
|
||||||
(assert (not= retval 24) "Process was *not* terminated by parent"))
|
(assert (not= retval 24) "Process was *not* terminated by parent"))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user