[LEDE-DEV] [PATCH] libubox: allow reading out the pid of uloop process in lua

Florian Eckert eckert.florian at googlemail.com
Tue Dec 13 03:34:31 PST 2016


Add Lua methode to get the forked pid of a uloop process

Signed-off-by: Florian Eckert <Eckert.Florian at googlemail.com>
---
 lua/uloop.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

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 }
 };
 
-- 
2.1.4




More information about the Lede-dev mailing list