diff options
author | Florian Eckert <eckert.florian@googlemail.com> | 2016-12-13 14:34:31 +0300 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2016-12-13 19:13:20 +0300 |
commit | 4a9f74f7ae6c092c731969c93f90ab4d6a07b524 (patch) | |
tree | a58b7ff990c175013c76af2de431f3b2c74a1a54 /lua | |
parent | 372e1e65efc3c94a0ba15ae4168e76dc6bffeea0 (diff) |
libubox: allow reading out the pid of uloop process in lua
Add Lua method to get the forked pid of a uloop process
Signed-off-by: Florian Eckert <Eckert.Florian@googlemail.com>
Diffstat (limited to 'lua')
-rw-r--r-- | lua/uloop.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lua/uloop.c b/lua/uloop.c index a78c2dc..1b0389f 100644 --- a/lua/uloop.c +++ b/lua/uloop.c @@ -288,8 +288,21 @@ static int ul_process_free(lua_State *L) return 1; } +static int ul_process_pid(lua_State *L) +{ + struct lua_uloop_process *proc = lua_touserdata(L, 1); + + if (proc->p.pid) { + lua_pushnumber(L, proc->p.pid); + return 1; + } + + return 0; +} + static const luaL_Reg process_m[] = { { "delete", ul_process_free }, + { "pid", ul_process_pid }, { NULL, NULL } }; |