1 |
commit: 9b2b36945ec4e0335e0375cc45e14c41c66d28ae |
2 |
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Mar 29 09:16:15 2016 +0000 |
4 |
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Mar 29 09:16:15 2016 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=9b2b3694 |
7 |
|
8 |
sandbox: allow user to force SIGKILL |
9 |
|
10 |
Sometimes the child process can get wedged and not respond to CTRL+C, |
11 |
so add an escape hatch so the user can easily force SIGKILL. |
12 |
|
13 |
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org> |
14 |
|
15 |
src/sandbox.c | 12 ++++++++++-- |
16 |
1 file changed, 10 insertions(+), 2 deletions(-) |
17 |
|
18 |
diff --git a/src/sandbox.c b/src/sandbox.c |
19 |
index c668ab6..503ad0b 100644 |
20 |
--- a/src/sandbox.c |
21 |
+++ b/src/sandbox.c |
22 |
@@ -128,13 +128,21 @@ static void print_sandbox_log(char *sandbox_log) |
23 |
sb_eerror("--------------------------------------------------------------------------------\n"); |
24 |
} |
25 |
|
26 |
+static int stop_count = 5; |
27 |
+ |
28 |
static void stop(int signum) |
29 |
{ |
30 |
if (0 == stop_called) { |
31 |
stop_called = signum; |
32 |
sb_warn("caught signal %d in pid %d", signum, getpid()); |
33 |
- } else |
34 |
- sb_warn("signal already caught and busy still cleaning up!"); |
35 |
+ } else if (--stop_count) { |
36 |
+ sb_warn("Send signal %i more time%s to force SIGKILL", |
37 |
+ stop_count, stop_count == 1 ? "" : "s"); |
38 |
+ } else { |
39 |
+ /* This really should kill all children; see usr1_handler. */ |
40 |
+ kill(child_pid, SIGKILL); |
41 |
+ stop_count = 1; |
42 |
+ } |
43 |
} |
44 |
|
45 |
static void usr1_handler(int signum, siginfo_t *siginfo, void *ucontext) |