summaryrefslogtreecommitdiff
path: root/zyklonb.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-06-15 01:29:20 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-06-15 01:29:20 +0200
commitac466d5ac94003a78c1fef5fd4a93269b0a0c957 (patch)
tree060d674f17597c9a6c3aff5de61827554eba6fda /zyklonb.c
parente8aefd9f962b9056196b7fb02b3ba100e0563e26 (diff)
downloadxK-ac466d5ac94003a78c1fef5fd4a93269b0a0c957.tar.gz
xK-ac466d5ac94003a78c1fef5fd4a93269b0a0c957.tar.xz
xK-ac466d5ac94003a78c1fef5fd4a93269b0a0c957.zip
ZyklonB: allow killing zombies
Asking to terminate the process twice now forcefully kills all plugins.
Diffstat (limited to 'zyklonb.c')
-rw-r--r--zyklonb.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/zyklonb.c b/zyklonb.c
index aef0372..7760ed1 100644
--- a/zyklonb.c
+++ b/zyklonb.c
@@ -1818,19 +1818,40 @@ try_reap_plugin (struct bot_context *ctx)
}
static void
+kill_all_zombies (struct bot_context *ctx)
+{
+ for (struct plugin *plugin = ctx->plugins; plugin; plugin = plugin->next)
+ {
+ if (!plugin->is_zombie)
+ continue;
+
+ print_status ("forcefully killing a zombie of `%s' (PID %d)",
+ plugin->name, (int) plugin->pid);
+ kill (plugin->pid, SIGKILL);
+ }
+}
+
+static void
on_signal_pipe_readable (const struct pollfd *fd, struct bot_context *ctx)
{
char dummy;
(void) read (fd->fd, &dummy, 1);
- if (g_termination_requested && !ctx->quitting)
+ if (g_termination_requested)
{
- // There may be a timer set to reconnect to the server
- irc_cancel_timers (ctx);
+ g_termination_requested = false;
+ if (!ctx->quitting)
+ {
+ // There may be a timer set to reconnect to the server
+ irc_cancel_timers (ctx);
- if (ctx->irc_fd != -1)
- irc_send (ctx, "QUIT :Terminated by signal");
- initiate_quit (ctx);
+ if (ctx->irc_fd != -1)
+ irc_send (ctx, "QUIT :Terminated by signal");
+ initiate_quit (ctx);
+ }
+ else
+ // Disregard proper termination, just kill all the children
+ kill_all_zombies (ctx);
}
// Reap all dead children (since the signal pipe may overflow etc. we run