ZyklonB: allow killing zombies

Asking to terminate the process twice now forcefully kills all plugins.
This commit is contained in:
Přemysl Eric Janouch 2015-06-15 01:29:20 +02:00
parent e8aefd9f96
commit ac466d5ac9

View File

@ -1817,13 +1817,30 @@ try_reap_plugin (struct bot_context *ctx)
return true;
}
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)
{
g_termination_requested = false;
if (!ctx->quitting)
{
// There may be a timer set to reconnect to the server
irc_cancel_timers (ctx);
@ -1832,6 +1849,10 @@ on_signal_pipe_readable (const struct pollfd *fd, struct bot_context *ctx)
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
// waitpid() in a loop to return all the zombies it knows about).