diff options
author | Richard Ipsum <richardipsum@fastmail.co.uk> | 2018-06-22 21:36:19 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2018-06-26 16:55:46 +0100 |
commit | 82324d028766094593f10ff9e17b38b266c96864 (patch) | |
tree | a5da87fa0c2ee08248e0ca57c57538548a7fc8b6 | |
parent | 8ce58c3259361e904033f88d83e958765181d8a3 (diff) | |
download | luxio-82324d028766094593f10ff9e17b38b266c96864.tar.gz |
Bind setsid(2)
-rw-r--r-- | luxio.c | 18 | ||||
-rwxr-xr-x | tests/test-setsid.lua | 7 |
2 files changed, 24 insertions, 1 deletions
@@ -743,7 +743,22 @@ luxio_getpgrp(lua_State *L) return 1; } -/* TODO: setsid() 4.3.2 */ +static int +luxio_setsid(lua_State *L) +{ + pid_t sid; + + sid = setsid(); + + lua_pushinteger(L, sid); + + if (sid < 0) { + lua_pushinteger(L, errno); + return 2; + } + + return 1; +} /* TODO: setpgid() 4.3.3 */ /*** System identification. @@ -4473,6 +4488,7 @@ luxio_functions[] = { { "getegid", luxio_getegid }, { "setuid", luxio_setuid }, { "setgid", luxio_setgid }, + { "setsid", luxio_setsid }, { "getlogin", luxio_getlogin }, { "uname", luxio_uname }, diff --git a/tests/test-setsid.lua b/tests/test-setsid.lua new file mode 100755 index 0000000..c720bd6 --- /dev/null +++ b/tests/test-setsid.lua @@ -0,0 +1,7 @@ +local l = require "luxio" + +local child = l.fork() + +if child == 0 then + print("session ID: " .. l.setsid()) +end |