supervise-daemon: multiple fixes

- Harden against dying by handling all signals that would terminate the
program and adding --reexec support
- factor the supervisor into its own function
- fix test for whether we are already running
This commit is contained in:
William Hubbs
2017-10-24 10:26:18 -05:00
parent 35b1996704
commit fdce4769f2
3 changed files with 349 additions and 246 deletions

View File

@ -217,6 +217,18 @@ signal_setup(int sig, void (*handler)(int))
return sigaction(sig, &sa, NULL);
}
int
signal_setup_restart(int sig, void (*handler)(int))
{
struct sigaction sa;
memset(&sa, 0, sizeof (sa));
sigemptyset(&sa.sa_mask);
sa.sa_handler = handler;
sa.sa_flags = SA_RESTART;
return sigaction(sig, &sa, NULL);
}
int
svc_lock(const char *applet)
{