diff options
author | Asbjørn Sloth Tønnesen <ast@2e8.dk> | 2016-01-07 17:30:32 +0000 |
---|---|---|
committer | Emil Renner Berthing <esmil@mailme.dk> | 2016-01-08 00:20:12 +0100 |
commit | 530537500af5458eff684765d47e841ca46cdc16 (patch) | |
tree | 81de57c9540216d106edaee603ecdf9e2ba92a30 | |
parent | 5b5127bbdca8fa036f64cfa4481aa9a932c48b21 (diff) | |
download | lem-530537500af5458eff684765d47e841ca46cdc16.tar.gz lem-530537500af5458eff684765d47e841ca46cdc16.tar.xz lem-530537500af5458eff684765d47e841ca46cdc16.zip |
signal: sigchld: export pid information
Signed-off-by: Asbjørn Sloth Tønnesen <ast@2e8.dk>
-rw-r--r-- | lem/signal/core.c | 9 | ||||
-rwxr-xr-x | 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)) |