From 530537500af5458eff684765d47e841ca46cdc16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= Date: Thu, 7 Jan 2016 17:30:32 +0000 Subject: signal: sigchld: export pid information MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Asbjørn Sloth Tønnesen --- lem/signal/core.c | 9 ++++++++- test/signal.lua | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lem/signal/core.c b/lem/signal/core.c index 2f6f228..45be7fc 100644 --- a/lem/signal/core.c +++ b/lem/signal/core.c @@ -164,6 +164,8 @@ signal_child_handler(EV_P_ struct ev_child *w, int revents) { lua_State *S; int status; + int pid = w->pid; + int rpid = w->rpid; (void)revents; @@ -177,7 +179,12 @@ signal_child_handler(EV_P_ struct ev_child *w, int revents) lua_pushinteger(S, SIGCHLD); status = w->rstatus; - lua_createtable(S, 0, 3); + lua_createtable(S, 0, 5); + + lua_pushinteger(S, pid); + lua_setfield(S, -2, "pid"); + lua_pushinteger(S, rpid); + lua_setfield(S, -2, "rpid"); if (WIFEXITED(status)) { lua_pushinteger(S, WEXITSTATUS(status)); diff --git a/test/signal.lua b/test/signal.lua index 75e5429..38896a0 100755 --- a/test/signal.lua +++ b/test/signal.lua @@ -28,7 +28,7 @@ local sleeper = utils.newsleeper() assert(signal.register('sigchld', function(signum, ev) if ev.type == 'exited' then - print('child ' .. ev.type .. ' with status ' .. ev.status) + print('child ' .. ev.rpid .. ' ' .. ev.type .. ' with status ' .. ev.status) end end)) -- cgit v1.2.1