From 1ee80926ffbfd4da7df50e5f2199ed49683b26be Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Mon, 9 Jan 2017 19:40:59 +0100 Subject: [PATCH] Fix error message, ignore SIGINT in parent Signed-off-by: Tobias Ulmer --- Changelog | 1 + generic/e2lib.lua | 6 ++++++ generic/le2lib.c | 11 +++++++++++ global/e2.lua | 12 ++++++++++-- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 1e73b7d..0e213fc 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ NEXT: + * Fix doubled up error message on Control-C * Fix e2factory sometimes ignoring Control-C * Fix unintended modification of the git index in working source directory. * Add sha256 support to e2source file config diff --git a/generic/e2lib.lua b/generic/e2lib.lua index 8f495a9..d41cfdb 100644 --- a/generic/e2lib.lua +++ b/generic/e2lib.lua @@ -335,6 +335,12 @@ function e2lib.setpgid(pid, pgid) return le2lib.setpgid(pid, pgid) end +--- Ignore SIGINT +-- @raise error on failure +function e2lib.ignore_sigint() + le2lib.ignore_sigint() +end + --- Send signal to process. -- @param pid Process ID to signal (number). -- @param sig Signal number. diff --git a/generic/le2lib.c b/generic/le2lib.c index c65b0af..17431fd 100644 --- a/generic/le2lib.c +++ b/generic/le2lib.c @@ -785,6 +785,16 @@ do_mkdir(lua_State *lua) return 1; } +static int +ignore_sigint(lua_State *L) +{ + if (signal(SIGINT, SIG_IGN) == SIG_ERR) { + return luaL_error(L, "signal: %s", strerror(errno)); + } + + return 0; +} + static int do_kill(lua_State *lua) { @@ -945,6 +955,7 @@ static luaL_Reg lib[] = { { "fork", lua_fork }, { "getpid", do_getpid }, { "hardlink", do_hardlink }, + { "ignore_sigint", ignore_sigint }, { "kill", do_kill }, { "mkdir", do_mkdir }, { "mkdtemp", do_mkdtemp }, diff --git a/global/e2.lua b/global/e2.lua index 67bd144..b6c119d 100644 --- a/global/e2.lua +++ b/global/e2.lua @@ -94,11 +94,19 @@ local function e2(arg) end e2lib.log(3, "calling " .. e2call.tool) - - rc, re = e2lib.callcmd(cmd, {}, nil, env) + e2lib.ignore_sigint() + rc, re = e2lib.callcmd(cmd, {}, nil, env, true) if not rc then error(re) end + local sig + rc, re, sig = e2lib.wait(rc) + if not rc then + error(re) + end + + e2lib.logf(4, "%s returned: exit status: %d pid: %d signal: %d", + e2call.tool, rc, re, sig or 0) return nil, rc end -- 2.39.5