mirror of
https://github.com/pygos/init.git
synced 2024-11-05 12:17:10 +01:00
David Oberhollenzer
028394b8a5
This commit add the ability to initd to reload the service configuration while running. The new configuration is merged with the existing one as follows: For each target: - If the existing service list is not NULL, we have not started that target yet. Simply replace it with the new list. - If it is NULL, the services have already been started. - First, remove all entries for services in that target that no loner exist (except from the 'running' list). - Second, add new services that we don't have yet. Treat them as recently diseased and let the user start them manualy. Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
42 lines
693 B
C
42 lines
693 B
C
/* SPDX-License-Identifier: ISC */
|
|
#include <stdio.h>
|
|
|
|
#include "init.h"
|
|
|
|
int sigsetup(void)
|
|
{
|
|
sigset_t mask;
|
|
int sfd;
|
|
|
|
sigfillset(&mask);
|
|
if (sigprocmask(SIG_SETMASK, &mask, NULL) == -1) {
|
|
perror("sigprocmask");
|
|
return -1;
|
|
}
|
|
|
|
sigemptyset(&mask);
|
|
sigaddset(&mask, SIGCHLD);
|
|
sigaddset(&mask, SIGINT);
|
|
sigaddset(&mask, SIGTERM);
|
|
sigaddset(&mask, SIGUSR1);
|
|
sigaddset(&mask, SIGHUP);
|
|
|
|
sfd = signalfd(-1, &mask, SFD_CLOEXEC);
|
|
if (sfd == -1) {
|
|
perror("signalfd");
|
|
return -1;
|
|
}
|
|
|
|
if (reboot(LINUX_REBOOT_CMD_CAD_OFF))
|
|
perror("cannot disable CTRL+ALT+DEL");
|
|
|
|
return sfd;
|
|
}
|
|
|
|
void sigreset(void)
|
|
{
|
|
sigset_t mask;
|
|
|
|
sigemptyset(&mask);
|
|
sigprocmask(SIG_SETMASK, &mask, NULL);
|
|
}
|