diff options
author | Steven Barth <steven@midlink.org> | 2009-03-10 20:59:56 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2009-03-10 20:59:56 +0000 |
commit | a125a64a154247e3c2979900d8a63c30fdaa7a34 (patch) | |
tree | 5339d4129191e0fb0ec5862f66876234ae64d9fc /libs/nixio/src/process.c | |
parent | 68a95e68067417714a52aedef4372f631a5ca6a8 (diff) |
Be nice()
Diffstat (limited to 'libs/nixio/src/process.c')
-rw-r--r-- | libs/nixio/src/process.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/libs/nixio/src/process.c b/libs/nixio/src/process.c index af44484da..0d60ed190 100644 --- a/libs/nixio/src/process.c +++ b/libs/nixio/src/process.c @@ -149,12 +149,27 @@ static int nixio_setuid(lua_State *L) { return nixio__pstatus(L, !setuid(uid)); } +static int nixio_nice(lua_State *L) { + int nval = luaL_checkint(L, 1); + + errno = 0; + nval = nice(nval); + + if (nval == -1 && errno) { + return nixio__perror(L); + } else { + lua_pushinteger(L, nval); + return 1; + } +} + /* module table */ static const luaL_reg R[] = { {"fork", nixio_fork}, {"wait", nixio_wait}, {"kill", nixio_kill}, + {"nice", nixio_nice}, {"getpid", nixio_getpid}, {"getppid", nixio_getppid}, {"getuid", nixio_getuid}, |