From b3311674d2073a0fdea35f033dcc06d6373d4873 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 28 Jun 2018 15:28:14 +0200 Subject: [PATCH] awesome.kill: allow negative PIDs (and 0) to support process groups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From `kill(3p)`: > If pid is greater than 0, sig shall be sent to the process whose > process ID is equal to pid. > If pid is 0, sig shall be sent to all processes (excluding an > unspecified set of system processes) whose process group ID is equal to > the process group ID of the sender, and for which the process has > permission to send a signal. > If pid is −1, sig shall be sent to all processes (excluding an > unspecified set of system processes) for which the process has > permission to send that signal. > If pid is negative, but not −1, sig shall be sent to all processes > (excluding an unspecified set of system processes) whose process group > ID is equal to the absolute value of pid, and for which the process has > permission to send a signal. --- luaa.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/luaa.c b/luaa.c index 698773b19..ffc6e5ee1 100644 --- a/luaa.c +++ b/luaa.c @@ -254,7 +254,8 @@ luaA_restart(lua_State *L) /** Send a signal to a process identified by its process id. See * `awesome.unix_signal` for a list of signals. - * @tparam integer pid Process identifier + * @tparam integer pid Process identifier. 0 and negative values have special + * meaning. See `man 3 kill`. * @tparam integer sig Signal number * @treturn boolean true if the signal was successfully sent, else false * @function kill @@ -262,7 +263,7 @@ luaA_restart(lua_State *L) static int luaA_kill(lua_State *L) { - int pid = luaA_checknumber_range(L, 1, 1, INT_MAX); + int pid = lua_tonumber(L, 1); int sig = luaA_checknumber_range(L, 2, 0, INT_MAX); int result = kill(pid, sig);