]> git.e2factory.org Git - e2factory.git/commitdiff
e2lib: add setpgid
authorTobias Ulmer <tu@emlix.com>
Mon, 9 Jan 2017 12:41:33 +0000 (13:41 +0100)
committerTobias Ulmer <tu@emlix.com>
Mon, 9 Jan 2017 12:41:36 +0000 (13:41 +0100)
currently unused

Signed-off-by: Tobias Ulmer <tu@emlix.com>
generic/e2lib.lua
generic/le2lib.c

index 35cae72a3d9c8977e35f6ee87e60ada19a61897e..8f495a9c393464ba998c2162b028bca84d5ec663 100644 (file)
@@ -327,6 +327,14 @@ function e2lib.getpid()
     return le2lib.getpid()
 end
 
+--- Set process group ID.
+-- @pid process id
+-- @pgid process group id
+-- @raise error on failure.
+function e2lib.setpgid(pid, pgid)
+    return le2lib.setpgid(pid, pgid)
+end
+
 --- Send signal to process.
 -- @param pid Process ID to signal (number).
 -- @param sig Signal number.
index d56addc18592cd38d80fdccf47383c0c55e72b81..c65b0afa26d8bf0e84d3770e9d8c59245010ebfb 100644 (file)
@@ -481,6 +481,19 @@ do_getpid(lua_State *lua) {
        return 1;
 }
 
+static int
+do_setpgid(lua_State *L)
+{
+       int rc, pid, pgid;
+
+       pid = luaL_checkint(L, 1);
+       pgid = luaL_checkint(L, 2);
+       if (setpgid(pid, pgid) != 0)
+               return luaL_error(L, "setpgid: %s", strerror(errno));
+
+       return 0;
+}
+
 static int
 do_unlink(lua_State *lua)
 {
@@ -940,6 +953,7 @@ static luaL_Reg lib[] = {
        { "poll", poll_fd },
        { "rmdir", do_rmdir },
        { "setenv", do_setenv },
+       { "setpgid", do_setpgid },
        { "signal_reset", signal_reset },
        { "stat", get_file_statistics },
        { "symlink", create_symlink },