]> git.e2factory.org Git - e2factory.git/commitdiff
le2lib: add a ioctl(TIOCSIG) wrapper function
authorTobias Ulmer <tu@emlix.com>
Tue, 12 Feb 2019 18:52:44 +0000 (19:52 +0100)
committerTobias Ulmer <tu@emlix.com>
Tue, 12 Feb 2019 18:52:44 +0000 (19:52 +0100)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
generic/le2lib.c

index b0d32e177e732f8af20ac6ff5b548b4457f5c84b..ceda311c95b174b7c19d98102a6947ce7d51d48f 100644 (file)
@@ -18,6 +18,7 @@
  */
 
 #include <sys/utsname.h>
+#include <sys/ioctl.h>
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -911,6 +912,18 @@ signal_unblock(lua_State *lua)
        return 0;
 }
 
+static int
+ioctl_tiocsig_sigint(lua_State *L)
+{
+       /* master fd of the pseudo terminal */
+       int fd = luaL_checkinteger(L, 1);
+
+       if (ioctl(fd, TIOCSIG, SIGINT) < 0)
+               return luaL_error(L, "ioctl(TIOCSIG, SIGINT) failed: %s",
+                   strerror(errno));
+       return 0;
+}
+
 static int
 do_forkpty(lua_State *L)
 {
@@ -946,6 +959,7 @@ static luaL_Reg lib[] = {
        { "forkpty", do_forkpty },
        { "getpid", do_getpid },
        { "hardlink", do_hardlink },
+       { "ioctl_tiocsig_sigint", ioctl_tiocsig_sigint },
        { "kill", do_kill },
        { "mkdir", do_mkdir },
        { "mkdtemp", do_mkdtemp },