diff options
author | Christian Pointner <equinox@spreadspace.org> | 2010-11-22 17:01:30 +0000 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2010-11-22 17:01:30 +0000 |
commit | 0d5e167cc0411f58ef226349d096a54a7369d9e0 (patch) | |
tree | 8b0e01671c76a27a81d6cb5fe8872871b29a8118 | |
parent | added error pipe in case execve returns - not working yet.. (diff) |
added child clear (not called yet)
git-svn-id: https://svn.spreadspace.org/gcsd/trunk@48 ac14a137-c7f1-4531-abe0-07747231d213
-rw-r--r-- | src/l_util.c | 17 |
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); |