Commit f9526a52 authored by Pål Hermunn Johansen's avatar Pål Hermunn Johansen

Move killing the child process into separate function

A new function, kill_child() is introduced, so that kill() is only
called from this function. This is a preparation of fixing the jail
implementation.
parent c6efe045
......@@ -457,6 +457,14 @@ mgt_launch_child(struct cli *cli)
* Cleanup when child dies.
*/
static int
kill_child(void) {
if (MGT_FEATURE(FEATURE_NO_COREDUMP))
return (kill(child_pid, SIGKILL));
else
return (kill(child_pid, SIGQUIT));
}
static void
mgt_reap_child(void)
{
......@@ -506,10 +514,7 @@ mgt_reap_child(void)
VSB_printf(vsb, "Child (%jd) not dying, killing", (intmax_t)r);
/* Kick it Jim... */
if (MGT_FEATURE(FEATURE_NO_COREDUMP))
(void)kill(child_pid, SIGKILL);
else
(void)kill(child_pid, SIGQUIT);
(void)kill_child();
r = waitpid(child_pid, &status, 0);
}
if (r != child_pid)
......@@ -588,17 +593,12 @@ mgt_reap_child(void)
void
MGT_Child_Cli_Fail(void)
{
int i;
if (child_state != CH_RUNNING)
return;
if (child_pid < 0)
return;
if (MGT_FEATURE(FEATURE_NO_COREDUMP))
i = kill(child_pid, SIGKILL);
else
i = kill(child_pid, SIGQUIT);
if (i == 0)
if (kill_child() == 0)
MGT_complain(C_ERR, "Child (%jd) not responding to CLI,"
" killing it.", (intmax_t)child_pid);
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment