mirror of
https://github.com/troglobit/finit.git
synced 2026-10-24 11:54:36 +00:00
Support touching custom PID files
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
68e7bcba4c
commit
e1b87d707f
2 files changed
+21
-6
No files matched your search
+15
-1
@@ -25,6 +25,7 @@
|
||||
#include "config.h" /* Generated by configure script */
|
||||
|
||||
#include <ctype.h> /* isblank() */
|
||||
#include <sched.h> /* sched_yield() */
|
||||
#include <string.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/wait.h>
|
||||
@@ -430,6 +431,8 @@ static int service_stop(svc_t *svc)
|
||||
*/
|
||||
static int service_restart(svc_t *svc)
|
||||
{
|
||||
int rc;
|
||||
|
||||
/* Ignore if finit is SIGSTOP'ed */
|
||||
if (is_norespawn())
|
||||
return 1;
|
||||
@@ -449,7 +452,15 @@ static int service_restart(svc_t *svc)
|
||||
svc_starting(svc);
|
||||
|
||||
_d("Sending SIGHUP to PID %d", svc->pid);
|
||||
return print_result(kill(svc->pid, SIGHUP));
|
||||
rc = kill(svc->pid, SIGHUP);
|
||||
|
||||
/* Service does not maintain a PID file on its own */
|
||||
if (svc_has_pidfile(svc)) {
|
||||
sched_yield();
|
||||
touch(pid_file(svc));
|
||||
}
|
||||
|
||||
return print_result(rc);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -686,6 +697,9 @@ recreate:
|
||||
if (desc)
|
||||
strlcpy(svc->desc, desc, sizeof(svc->desc));
|
||||
|
||||
/* Always clear svc PID file, for now. See TODO */
|
||||
svc->pidfile[0] = 0;
|
||||
/* Decode any optional pid:/optional/path/to/file.pid */
|
||||
if (pid && svc_is_daemon(svc) && pid_file_parse(svc, pid))
|
||||
_e("Invalid 'pid' argument to service: %s", pid);
|
||||
|
||||
|
||||
Reference in new issue
Block a user