Track oldpid of services to fix empty pid in restart message

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2021-03-12 00:13:15 +01:00
parent 3d98ad293b
commit 8aba63a9e3
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -621,6 +621,7 @@ static void service_cleanup(svc_t *svc)
basename(svc->cmd), fn);
/* No longer running, update books. */
svc->oldpid = svc->pid;
svc->start_time = svc->pid = 0;
}
@@ -1284,7 +1285,7 @@ static void service_retry(svc_t *svc)
_d("%s crashed, trying to start it again, attempt %d", svc->cmd, *restart_cnt);
logit(LOG_CONSOLE | LOG_WARNING, "Service %s[%d] died, restarting (%d/%d)",
svc_ident(svc, NULL, 0), svc->pid, *restart_cnt, SVC_RESPAWN_MAX);
svc_ident(svc, NULL, 0), svc->oldpid, *restart_cnt, SVC_RESPAWN_MAX);
svc_unblock(svc);
service_step(svc);
+1 -1
View File
@@ -98,7 +98,7 @@ typedef struct svc {
/* Service details */
int sighalt; /* Signal to stop prorcess, default: SIGTERM */
int killdelay; /* Delay in msec before sending SIGKILL */
pid_t pid;
pid_t oldpid, pid;
char pidfile[256];
long start_time; /* Start time, as seconds since boot, from sysinfo() */
int started; /* Set for run/task/sysv to track if started */