summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/l_util.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/l_util.c b/src/l_util.c
index 6ef6236..3697c09 100644
--- a/src/l_util.c
+++ b/src/l_util.c
@@ -316,6 +316,23 @@ child_t* child_find(lua_State *L, pid_t pid)
return NULL;
}
+void child_clear(lua_State *L, pid_t pid)
+{
+ lua_getglobal(L, LUA_UTILLIBNAME);
+ lua_getfield(L, -1, LUA_UTILCHLIDRENNAME);
+ child_t* first = lua_touserdata(L, -1);
+ lua_pop(L, 1);
+ lua_pushlightuserdata(L, NULL);
+ lua_setfield(L, -2, LUA_UTILCHLIDRENNAME);
+
+ while(first) {
+ child_t* tmp = first;
+ first = tmp->next_;
+ close(tmp->fd_);
+ free(tmp);
+ }
+}
+
static int l_util_exec(lua_State *L)
{
const char* script = luaL_checkstring(L, 1);