diff options
author | Mike Frysinger <vapier@gentoo.org> | 2016-03-29 05:16:15 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2016-03-29 05:16:15 -0400 |
commit | 9b2b36945ec4e0335e0375cc45e14c41c66d28ae (patch) | |
tree | 4f89f33c84e51128d500ad1bbab7c1fc86b0d472 /src | |
parent | libsandbox: make check_syscall ISE a little more useful (diff) | |
download | sandbox-9b2b36945ec4e0335e0375cc45e14c41c66d28ae.tar.gz sandbox-9b2b36945ec4e0335e0375cc45e14c41c66d28ae.tar.bz2 sandbox-9b2b36945ec4e0335e0375cc45e14c41c66d28ae.zip |
sandbox: allow user to force SIGKILL
Sometimes the child process can get wedged and not respond to CTRL+C,
so add an escape hatch so the user can easily force SIGKILL.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/sandbox.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/sandbox.c b/src/sandbox.c index c668ab6..503ad0b 100644 --- a/src/sandbox.c +++ b/src/sandbox.c @@ -128,13 +128,21 @@ static void print_sandbox_log(char *sandbox_log) sb_eerror("--------------------------------------------------------------------------------\n"); } +static int stop_count = 5; + static void stop(int signum) { if (0 == stop_called) { stop_called = signum; sb_warn("caught signal %d in pid %d", signum, getpid()); - } else - sb_warn("signal already caught and busy still cleaning up!"); + } else if (--stop_count) { + sb_warn("Send signal %i more time%s to force SIGKILL", + stop_count, stop_count == 1 ? "" : "s"); + } else { + /* This really should kill all children; see usr1_handler. */ + kill(child_pid, SIGKILL); + stop_count = 1; + } } static void usr1_handler(int signum, siginfo_t *siginfo, void *ucontext) |