mirror of
https://github.com/troglobit/finit.git
synced 2026-10-27 12:20:54 +00:00
Fix ordering issue, pid is unset for kill(-pid, SIGKILL) op
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
242fe54afd
commit
46ccdc3820
1 file changed
+6
-6
+6
-6
@@ -659,14 +659,14 @@ static void service_cleanup(svc_t *svc)
|
|||||||
{
|
{
|
||||||
char *fn;
|
char *fn;
|
||||||
|
|
||||||
|
/* PID collected, cancel any pending SIGKILL */
|
||||||
|
service_timeout_cancel(svc);
|
||||||
|
|
||||||
fn = pid_file(svc);
|
fn = pid_file(svc);
|
||||||
if (fn && remove(fn) && errno != ENOENT)
|
if (fn && remove(fn) && errno != ENOENT)
|
||||||
logit(LOG_CRIT, "Failed removing service %s pidfile %s",
|
logit(LOG_CRIT, "Failed removing service %s pidfile %s",
|
||||||
basename(svc->cmd), fn);
|
basename(svc->cmd), fn);
|
||||||
|
|
||||||
/* PID collected, cancel any pending SIGKILL */
|
|
||||||
service_timeout_cancel(svc);
|
|
||||||
|
|
||||||
/* No longer running, update books. */
|
/* No longer running, update books. */
|
||||||
if (svc_is_tty(svc) && svc->pid > 1)
|
if (svc_is_tty(svc) && svc->pid > 1)
|
||||||
utmp_set_dead(svc->pid); /* Set DEAD_PROCESS UTMP entry */
|
utmp_set_dead(svc->pid); /* Set DEAD_PROCESS UTMP entry */
|
||||||
@@ -1376,6 +1376,9 @@ void service_monitor(pid_t lost, int status)
|
|||||||
if (svc_is_starting(svc) && svc_is_forking(svc))
|
if (svc_is_starting(svc) && svc_is_forking(svc))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* Terminate any children in the same proess group, e.g. logit */
|
||||||
|
kill(-svc->pid, SIGKILL);
|
||||||
|
|
||||||
/* Try removing PID file (in case service does not clean up after itself) */
|
/* Try removing PID file (in case service does not clean up after itself) */
|
||||||
if (svc_is_daemon(svc) || svc_is_tty(svc)) {
|
if (svc_is_daemon(svc) || svc_is_tty(svc)) {
|
||||||
service_cleanup(svc);
|
service_cleanup(svc);
|
||||||
@@ -1387,9 +1390,6 @@ void service_monitor(pid_t lost, int status)
|
|||||||
svc->started = 0;
|
svc->started = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Terminate any children in the same proess group, e.g. logit */
|
|
||||||
kill(-svc->pid, SIGKILL);
|
|
||||||
|
|
||||||
/* No longer running, update books. */
|
/* No longer running, update books. */
|
||||||
svc->start_time = svc->pid = 0;
|
svc->start_time = svc->pid = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user