diff options
author | Steven Barth <steven@midlink.org> | 2009-03-09 22:19:47 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2009-03-09 22:19:47 +0000 |
commit | 68a95e68067417714a52aedef4372f631a5ca6a8 (patch) | |
tree | 4efc1d2e17cc70b1a2622e9941fdaddd1ef351d0 /libs/nixio/src/process.c | |
parent | 2e79c969c03cba4ecdb35ea71fd31613e85fb7ff (diff) |
nixio: Implement protable behaviour of signal(), export more error
constants
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 69f19b7ac..af44484da 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} }; |