From d2d56177747611fae53385663e0fe60d9d5157f4 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Sun, 30 Jan 2022 20:51:30 -0500 Subject: [PATCH] Changed signalling so it'll target the whole process group. --- src/api/process.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/api/process.c b/src/api/process.c index 999ccd40..c4ad0673 100644 --- a/src/api/process.c +++ b/src/api/process.c @@ -105,9 +105,9 @@ static bool signal_process(process_t* proc, signal_e sig) { } #else switch (sig) { - case SIGNAL_TERM: terminate = kill(proc->pid, SIGTERM) == 1; break; - case SIGNAL_KILL: terminate = kill(proc->pid, SIGKILL) == 1; break; - case SIGNAL_INTERRUPT: kill(proc->pid, SIGINT); break; + case SIGNAL_TERM: terminate = kill(-proc->pid, SIGTERM) == 1; break; + case SIGNAL_KILL: terminate = kill(-proc->pid, SIGKILL) == 1; break; + case SIGNAL_INTERRUPT: kill(-proc->pid, SIGINT); break; } #endif if (terminate) @@ -255,6 +255,7 @@ static int process_start(lua_State* L) { } return luaL_error(L, "Error running fork: %s.", strerror(errno)); } else if (!self->pid) { + setpgrp(); for (int stream = 0; stream < 3; ++stream) { if (new_fds[stream] == REDIRECT_DISCARD) { // Close the stream if we don't want it. close(self->child_pipes[stream][stream == STDIN_FD ? 0 : 1]); @@ -429,6 +430,7 @@ static int f_gc(lua_State* L) { close_fd(&self->child_pipes[STDIN_FD ][1]); close_fd(&self->child_pipes[STDOUT_FD][0]); close_fd(&self->child_pipes[STDERR_FD][0]); + poll_process(self, 10); return 0; }