aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--initd/Makemodule.am2
-rw-r--r--initd/init.h23
-rw-r--r--initd/main.c23
-rw-r--r--initd/runsvc.c5
-rw-r--r--initd/signal_linux.c42
5 files changed, 28 insertions, 67 deletions
diff --git a/initd/Makemodule.am b/initd/Makemodule.am
index 7e7fd37..9b2b7a6 100644
--- a/initd/Makemodule.am
+++ b/initd/Makemodule.am
@@ -1,4 +1,4 @@
-init_SOURCES = initd/main.c initd/init.h initd/signal_linux.c initd/runsvc.c
+init_SOURCES = initd/main.c initd/init.h initd/runsvc.c
init_SOURCES += initd/status.c initd/supervisor.c initd/initsock.c
init_CPPFLAGS = $(AM_CPPFLAGS)
init_CFLAGS = $(AM_CFLAGS)
diff --git a/initd/init.h b/initd/init.h
index 50f799a..6b68ef6 100644
--- a/initd/init.h
+++ b/initd/init.h
@@ -77,29 +77,6 @@ void supervisor_start(int id);
void supervisor_stop(int id);
-/********** signal_<platform>.c **********/
-
-/*
- Setup signal handling. Returns -1 on error, a file descriptor on
- success.
-
- The returned file descriptor can be polled and becomes readable
- when a signal arrives. Reading from it returns a signalfd_siginfo
- structure.
-
- The returned file descriptor has the close on exec flag set.
-
- The kernel is also told to send us SIGINT signals if a user presses
- the local equivalent of CTRL+ALT+DEL.
-*/
-int sigsetup(void);
-
-/*
- Undo everything that sigsetup() changed about signal handling and
- restore the default.
-*/
-void sigreset(void);
-
/********** initsock.c **********/
int init_socket_create(void);
diff --git a/initd/main.c b/initd/main.c
index 9cccdc5..e024c4e 100644
--- a/initd/main.c
+++ b/initd/main.c
@@ -96,6 +96,29 @@ void target_completed(int target)
}
}
+static int sigsetup(void)
+{
+ sigset_t mask;
+ int sfd;
+
+ sigfillset(&mask);
+ if (sigprocmask(SIG_SETMASK, &mask, NULL) == -1) {
+ perror("sigprocmask");
+ return -1;
+ }
+
+ 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;
+}
+
int main(void)
{
int i, ret, count;
diff --git a/initd/runsvc.c b/initd/runsvc.c
index 338a7de..7c1dc36 100644
--- a/initd/runsvc.c
+++ b/initd/runsvc.c
@@ -10,6 +10,7 @@
pid_t runsvc(service_t *svc)
{
char *argv[4], *envp[1];
+ sigset_t mask;
pid_t pid;
argv[0] = (char *)RUNSVCBIN;
@@ -25,7 +26,9 @@ pid_t runsvc(service_t *svc)
perror("fork");
if (pid == 0) {
- sigreset();
+ sigemptyset(&mask);
+ sigprocmask(SIG_SETMASK, &mask, NULL);
+
execve(argv[0], argv, envp);
perror(argv[0]);
exit(EXIT_FAILURE);
diff --git a/initd/signal_linux.c b/initd/signal_linux.c
deleted file mode 100644
index b19d715..0000000
--- a/initd/signal_linux.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/* 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);
-}