Commit 9a34ec5f authored by Lennart Poettering's avatar Lennart Poettering
Browse files

execute: only reset those signals to the default we really need to reset to the default

parent e1ce2c27
......@@ -23,8 +23,6 @@
* reinvestigate random seed, hwclock
* introduce serialized mode
* "disabled" load state?
* uid are 32bit
......@@ -63,8 +61,6 @@
* Add code to systemctl to wait for an operation to finish
* update to new libudev/tags
Regularly:
* look for close() vs. close_nointr() vs. close_nointr_nofail()
......
......@@ -783,7 +783,11 @@ int exec_spawn(ExecCommand *command,
/* child */
reset_all_signal_handlers();
/* We reset exactly these two signals, since they are
* the only ones we set to SIG_IGN in the main
* daemon. All others */
default_signals(SIGNALS_CRASH_HANLDER,
SIGNALS_IGNORE, -1);
if (sigemptyset(&ss) < 0 ||
sigprocmask(SIG_SETMASK, &ss, NULL) < 0) {
......
......@@ -41,6 +41,10 @@ struct CGroupBonding;
/* Abstract namespace! */
#define LOGGER_SOCKET "/org/freedesktop/systemd1/logger"
/* This doesn't really belong here, but I couldn't find a better place to put this. */
#define SIGNALS_CRASH_HANLDER SIGSEGV,SIGILL,SIGFPE,SIGBUS,SIGQUIT,SIGABRT
#define SIGNALS_IGNORE SIGKILL,SIGPIPE
typedef enum ExecInput {
EXEC_INPUT_NULL,
EXEC_INPUT_TTY,
......
......@@ -165,12 +165,7 @@ static void install_crash_handler(void) {
sa.sa_handler = crash;
sa.sa_flags = SA_NODEFER;
assert_se(sigaction(SIGSEGV, &sa, NULL) == 0);
assert_se(sigaction(SIGILL, &sa, NULL) == 0);
assert_se(sigaction(SIGFPE, &sa, NULL) == 0);
assert_se(sigaction(SIGBUS, &sa, NULL) == 0);
assert_se(sigaction(SIGQUIT, &sa, NULL) == 0);
assert_se(sigaction(SIGABRT, &sa, NULL) == 0);
sigaction_many(&sa, SIGNALS_CRASH_HANLDER, -1);
}
static int make_null_stdio(void) {
......@@ -569,8 +564,7 @@ int main(int argc, char *argv[]) {
assert_se(reset_all_signal_handlers() == 0);
/* If we are init, we can block sigkill. Yay. */
ignore_signal(SIGKILL);
ignore_signal(SIGPIPE);
ignore_signals(SIGNALS_IGNORE, -1);
if (running_as != MANAGER_SESSION)
if (parse_proc_cmdline() < 0)
......
......@@ -1735,14 +1735,59 @@ int release_terminal(void) {
return r;
}
int ignore_signal(int sig) {
int sigaction_many(const struct sigaction *sa, ...) {
va_list ap;
int r = 0, sig;
va_start(ap, sa);
while ((sig = va_arg(ap, int)) > 0)
if (sigaction(sig, sa, NULL) < 0)
r = -errno;
va_end(ap);
return r;
}
int ignore_signals(int sig, ...) {
struct sigaction sa;
va_list ap;
int r = 0;
zero(sa);
sa.sa_handler = SIG_IGN;
sa.sa_flags = SA_RESTART;
return sigaction(sig, &sa, NULL);
if (sigaction(sig, &sa, NULL) < 0)
r = -errno;
va_start(ap, sig);
while ((sig = va_arg(ap, int)) > 0)
if (sigaction(sig, &sa, NULL) < 0)
r = -errno;
va_end(ap);
return r;
}
int default_signals(int sig, ...) {
struct sigaction sa;
va_list ap;
int r = 0;
zero(sa);
sa.sa_handler = SIG_DFL;
sa.sa_flags = SA_RESTART;
if (sigaction(sig, &sa, NULL) < 0)
r = -errno;
va_start(ap, sig);
while ((sig = va_arg(ap, int)) > 0)
if (sigaction(sig, &sa, NULL) < 0)
r = -errno;
va_end(ap);
return r;
}
int close_pipe(int p[]) {
......
......@@ -28,6 +28,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
typedef uint64_t usec_t;
......@@ -223,7 +224,9 @@ int release_terminal(void);
int flush_fd(int fd);
int ignore_signal(int sig);
int ignore_signals(int sig, ...);
int default_signals(int sig, ...);
int sigaction_many(const struct sigaction *sa, ...);
int close_pipe(int p[]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment