diff options
Diffstat (limited to 'libs/nixio/src/process.c')
-rw-r--r-- | libs/nixio/src/process.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libs/nixio/src/process.c b/libs/nixio/src/process.c index 69f19b7ac1..af44484dad 100644 --- a/libs/nixio/src/process.c +++ b/libs/nixio/src/process.c @@ -36,6 +36,19 @@ static int nixio_fork(lua_State *L) { } } +static int nixio_signal(lua_State *L) { + int sig = luaL_checkinteger(L, 1); + const char *val = luaL_checkstring(L, 2); + + if (!strcmp(val, "ign") || !strcmp(val, "ignore")) { + return nixio__pstatus(L, signal(sig, SIG_IGN) != SIG_ERR); + } else if (!strcmp(val, "dfl") || !strcmp(val, "default")) { + return nixio__pstatus(L, signal(sig, SIG_DFL) != SIG_ERR); + } else { + return luaL_argerror(L, 2, "supported values: ign, dfl"); + } +} + static int nixio_wait(lua_State *L) { pid_t pidin = luaL_optinteger(L, 1, -1), pidout; int options = 0, status; @@ -148,6 +161,7 @@ static const luaL_reg R[] = { {"getgid", nixio_getgid}, {"setuid", nixio_setuid}, {"setgid", nixio_setgid}, + {"signal", nixio_signal}, {NULL, NULL} }; |