mirror of
https://github.com/janet-lang/janet
synced 2024-12-01 04:19:55 +00:00
Merge pull request #713 from yumaikas/fix-process-terminate-windows
Add TerminateProcess to janet_proc_gc and os_proc_kill on Windows
This commit is contained in:
commit
dc414f1239
@ -434,6 +434,7 @@ static int janet_proc_gc(void *p, size_t s) {
|
|||||||
JanetProc *proc = (JanetProc *) p;
|
JanetProc *proc = (JanetProc *) p;
|
||||||
#ifdef JANET_WINDOWS
|
#ifdef JANET_WINDOWS
|
||||||
if (!(proc->flags & JANET_PROC_CLOSED)) {
|
if (!(proc->flags & JANET_PROC_CLOSED)) {
|
||||||
|
TerminateProcess(proc->pHandle, 1);
|
||||||
CloseHandle(proc->pHandle);
|
CloseHandle(proc->pHandle);
|
||||||
CloseHandle(proc->tHandle);
|
CloseHandle(proc->tHandle);
|
||||||
}
|
}
|
||||||
@ -519,6 +520,7 @@ static Janet os_proc_kill(int32_t argc, Janet *argv) {
|
|||||||
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;
|
||||||
|
TerminateProcess(proc->pHandle, 1);
|
||||||
CloseHandle(proc->pHandle);
|
CloseHandle(proc->pHandle);
|
||||||
CloseHandle(proc->tHandle);
|
CloseHandle(proc->tHandle);
|
||||||
#else
|
#else
|
||||||
|
@ -47,6 +47,11 @@
|
|||||||
(assert-no-error "pipe stdin to process 2" (os/proc-wait p))
|
(assert-no-error "pipe stdin to process 2" (os/proc-wait p))
|
||||||
(assert (= "hello!" (string/trim x)) "round trip pipeline in process"))
|
(assert (= "hello!" (string/trim x)) "round trip pipeline in process"))
|
||||||
|
|
||||||
|
(let [p (os/spawn [janet "-e" `(do (ev/sleep 30) (os/exit 24)`] :p)]
|
||||||
|
(os/proc-kill p)
|
||||||
|
(def retval (os/proc-wait p))
|
||||||
|
(assert (not= retval 24) "Process was *not* terminated by parent"))
|
||||||
|
|
||||||
# Parallel subprocesses
|
# Parallel subprocesses
|
||||||
|
|
||||||
(defn calc-1
|
(defn calc-1
|
||||||
|
Loading…
Reference in New Issue
Block a user