ipsec starter gives the charon daemon 8s to terminate gracefully before killing the process brutally
This commit is contained in:
+28
-14
@@ -63,38 +63,46 @@ starter_charon_sigchild(pid_t pid)
|
||||
int
|
||||
starter_stop_charon (void)
|
||||
{
|
||||
pid_t pid;
|
||||
int i;
|
||||
pid_t pid = _charon_pid;
|
||||
|
||||
pid = _charon_pid;
|
||||
if (pid)
|
||||
{
|
||||
_stop_requested = 1;
|
||||
|
||||
/* be more and more aggressive */
|
||||
for (i = 0; i < 20 && (pid = _charon_pid) != 0; i++)
|
||||
for (i = 0; i < 50 && (pid = _charon_pid) != 0; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
kill(pid, SIGINT);
|
||||
else if (i < 10)
|
||||
kill(pid, SIGTERM);
|
||||
else if (i == 10)
|
||||
if (i == 0)
|
||||
{
|
||||
kill(pid, SIGKILL);
|
||||
plog("starter_stop_charon(): charon does not respond, sending KILL");
|
||||
kill(pid, SIGINT);
|
||||
}
|
||||
else if (i < 40)
|
||||
{
|
||||
kill(pid, SIGTERM);
|
||||
}
|
||||
else if (i == 40)
|
||||
{
|
||||
kill(pid, SIGKILL);
|
||||
plog("starter_stop_charon(): charon does not respond, sending KILL");
|
||||
}
|
||||
else
|
||||
kill(pid, SIGKILL);
|
||||
usleep(200000);
|
||||
{
|
||||
kill(pid, SIGKILL);
|
||||
}
|
||||
usleep(200000); /* sleep for 200 ms */
|
||||
}
|
||||
if (_charon_pid == 0)
|
||||
{
|
||||
plog("charon stopped after %d ms", 200*i);
|
||||
return 0;
|
||||
}
|
||||
plog("starter_stop_charon(): can't stop charon !!!");
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
plog("stater_stop_charon(): charon is not started...");
|
||||
plog("stater_stop_charon(): charon was not started...");
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -193,12 +201,18 @@ starter_start_charon (starter_config_t *cfg, bool no_fork)
|
||||
plog("charon too long to start... - kill kill");
|
||||
for (i = 0; i < 20 && (pid = _charon_pid) != 0; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
if (i == 0)
|
||||
{
|
||||
kill(pid, SIGINT);
|
||||
}
|
||||
else if (i < 10)
|
||||
{
|
||||
kill(pid, SIGTERM);
|
||||
}
|
||||
else
|
||||
{
|
||||
kill(pid, SIGKILL);
|
||||
}
|
||||
usleep(20000);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user