mirror of
https://github.com/troglobit/finit.git
synced 2026-11-08 16:11:10 +00:00
Track service start time using new jiffies() function
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
f6fa576270
commit
50f128cd1d
2 files changed
+6
-3
No files matched your search
+5
-3
@@ -41,6 +41,7 @@
|
|||||||
#include "service.h"
|
#include "service.h"
|
||||||
#include "sm.h"
|
#include "sm.h"
|
||||||
#include "tty.h"
|
#include "tty.h"
|
||||||
|
#include "util.h"
|
||||||
#include "utmp-api.h"
|
#include "utmp-api.h"
|
||||||
|
|
||||||
#define RESPAWN_MAX 10 /* Prevent endless respawn of faulty services. */
|
#define RESPAWN_MAX 10 /* Prevent endless respawn of faulty services. */
|
||||||
@@ -308,6 +309,7 @@ static int service_start(svc_t *svc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
svc->pid = pid;
|
svc->pid = pid;
|
||||||
|
svc->start_time = jiffies();
|
||||||
|
|
||||||
#ifdef INETD_ENABLED
|
#ifdef INETD_ENABLED
|
||||||
if (svc_is_inetd_conn(svc) && svc->inetd.type == SOCK_STREAM)
|
if (svc_is_inetd_conn(svc) && svc->inetd.type == SOCK_STREAM)
|
||||||
@@ -317,7 +319,7 @@ static int service_start(svc_t *svc)
|
|||||||
if (SVC_TYPE_RUN == svc->type) {
|
if (SVC_TYPE_RUN == svc->type) {
|
||||||
result = WEXITSTATUS(complete(svc->cmd, pid));
|
result = WEXITSTATUS(complete(svc->cmd, pid));
|
||||||
if (!svc_clean_bootstrap(svc)) {
|
if (!svc_clean_bootstrap(svc)) {
|
||||||
svc->pid = 0;
|
svc->start_time = svc->pid = 0;
|
||||||
svc_set_state(svc, SVC_STOPPING_STATE);
|
svc_set_state(svc, SVC_STOPPING_STATE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -433,7 +435,7 @@ static int service_restart(svc_t *svc)
|
|||||||
|
|
||||||
if (svc->pid <= 1) {
|
if (svc->pid <= 1) {
|
||||||
_d("Bad PID %d for %s, SIGHUP", svc->pid, svc->cmd);
|
_d("Bad PID %d for %s, SIGHUP", svc->pid, svc->cmd);
|
||||||
svc->pid = 0;
|
svc->start_time = svc->pid = 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -783,7 +785,7 @@ void service_monitor(pid_t lost)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* No longer running, update books. */
|
/* No longer running, update books. */
|
||||||
svc->pid = 0;
|
svc->start_time = svc->pid = 0;
|
||||||
service_step(svc);
|
service_step(svc);
|
||||||
|
|
||||||
/* Clean out any bootstrap tasks, they've had their time in the sun. */
|
/* Clean out any bootstrap tasks, they've had their time in the sun. */
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ typedef struct svc {
|
|||||||
|
|
||||||
/* Service details */
|
/* Service details */
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
long start_time; /* Start time, as seconds since boot, from sysinfo() */
|
||||||
const svc_state_t state; /* Paused, Reloading, Restart, Running, ... */
|
const svc_state_t state; /* Paused, Reloading, Restart, Running, ... */
|
||||||
svc_type_t type; /* Service, run, task, inetd, ... */
|
svc_type_t type; /* Service, run, task, inetd, ... */
|
||||||
int protected; /* Services like dbus-daemon & udev by Finit */
|
int protected; /* Services like dbus-daemon & udev by Finit */
|
||||||
|
|||||||
Reference in new issue
Block a user