* reinvestigate random seed, hwclock
-* introduce serialized mode
-
* "disabled" load state?
* uid are 32bit
* 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()
/* 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) {
/* 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,
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) {
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)
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[]) {
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
+#include <signal.h>
typedef uint64_t usec_t;
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[]);