2018-11-23 13:13:23 +01:00
|
|
|
/* SPDX-License-Identifier: ISC */
|
2018-04-15 13:21:34 +02:00
|
|
|
#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;
|
|
|
|
}
|
|
|
|
|
2018-09-01 00:00:40 +02:00
|
|
|
sigemptyset(&mask);
|
|
|
|
sigaddset(&mask, SIGCHLD);
|
|
|
|
sigaddset(&mask, SIGINT);
|
|
|
|
sigaddset(&mask, SIGTERM);
|
2019-03-25 16:32:45 +01:00
|
|
|
sigaddset(&mask, SIGUSR1);
|
2019-03-25 17:16:34 +01:00
|
|
|
sigaddset(&mask, SIGHUP);
|
2018-09-01 00:00:40 +02:00
|
|
|
|
2018-04-15 13:21:34 +02:00
|
|
|
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);
|
|
|
|
}
|