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>
This commit is contained in:
parent
372e1e65ef
commit
4a9f74f7ae
1 changed files with 13 additions and 0 deletions
13
lua/uloop.c
13
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 }
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue