From c2eb1165a4d1181b7c10837ceb4d3f1d377e1bd4 Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Tue, 12 Feb 2019 19:52:44 +0100 Subject: [PATCH] le2lib: add a ioctl(TIOCSIG) wrapper function Signed-off-by: Tobias Ulmer --- generic/le2lib.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/generic/le2lib.c b/generic/le2lib.c index b0d32e1..ceda311 100644 --- a/generic/le2lib.c +++ b/generic/le2lib.c @@ -18,6 +18,7 @@ */ #include +#include #include #include @@ -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 }, -- 2.39.5