From: Mike Yuan Date: Sat, 4 Jan 2025 13:49:14 +0000 (+0100) Subject: tree-wide: make sigactions static const X-Git-Tag: v258-rc1~1706^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5734893f8291dff62ae8b043e2962856be0eb50e;p=thirdparty%2Fsystemd.git tree-wide: make sigactions static const --- diff --git a/src/basic/sigbus.c b/src/basic/sigbus.c index e8d2fdb79a0..307e879bf59 100644 --- a/src/basic/sigbus.c +++ b/src/basic/sigbus.c @@ -121,7 +121,7 @@ static void sigbus_handler(int sn, siginfo_t *si, void *data) { } void sigbus_install(void) { - struct sigaction sa = { + static const struct sigaction sa = { .sa_sigaction = sigbus_handler, .sa_flags = SA_SIGINFO, }; diff --git a/src/core/crash-handler.c b/src/core/crash-handler.c index e964c897d22..056ac4b347c 100644 --- a/src/core/crash-handler.c +++ b/src/core/crash-handler.c @@ -52,8 +52,13 @@ _noreturn_ void freeze_or_exit_or_reboot(void) { } _noreturn_ static void crash(int sig, siginfo_t *siginfo, void *context) { - struct sigaction sa; + static const struct sigaction sa_nocldwait = { + .sa_handler = SIG_IGN, + .sa_flags = SA_NOCLDSTOP|SA_NOCLDWAIT|SA_RESTART, + }; + pid_t pid; + int r; /* NB: 💣 💣 💣 This is a signal handler, most likely executed in a situation where we have corrupted * memory. Thus: please avoid any libc memory allocation here, or any functions that internally use @@ -94,7 +99,6 @@ _noreturn_ static void crash(int sig, siginfo_t *siginfo, void *context) { _exit(EXIT_EXCEPTION); } else { siginfo_t status; - int r; if (siginfo) { if (siginfo->si_pid == 0) @@ -141,13 +145,8 @@ _noreturn_ static void crash(int sig, siginfo_t *siginfo, void *context) { if (arg_crash_chvt >= 0) (void) chvt(arg_crash_chvt); - sa = (struct sigaction) { - .sa_handler = SIG_IGN, - .sa_flags = SA_NOCLDSTOP|SA_NOCLDWAIT|SA_RESTART, - }; - /* Let the kernel reap children for us */ - (void) sigaction(SIGCHLD, &sa, NULL); + (void) sigaction(SIGCHLD, &sa_nocldwait, NULL); if (arg_crash_shell) { log_notice("Executing crash shell..."); diff --git a/src/core/manager.c b/src/core/manager.c index e75c760b6fd..f4fbeaa142c 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -517,7 +517,7 @@ static int manager_enable_special_signals(Manager *m) { #define RTSIG_IF_AVAILABLE(signum) (signum <= SIGRTMAX ? signum : -1) static int manager_setup_signals(Manager *m) { - struct sigaction sa = { + static const struct sigaction sa = { .sa_handler = SIG_DFL, .sa_flags = SA_NOCLDSTOP|SA_RESTART, }; diff --git a/src/coredump/coredumpctl.c b/src/coredump/coredumpctl.c index e7d0dd34c0d..f01db21f88e 100644 --- a/src/coredump/coredumpctl.c +++ b/src/coredump/coredumpctl.c @@ -1170,13 +1170,14 @@ static void sigterm_handler(int signal, siginfo_t *info, void *ucontext) { } static int run_debug(int argc, char **argv, void *userdata) { - _cleanup_(sd_journal_closep) sd_journal *j = NULL; - _cleanup_free_ char *exe = NULL, *path = NULL; - _cleanup_strv_free_ char **debugger_call = NULL; - struct sigaction sa = { + static const struct sigaction sa = { .sa_sigaction = sigterm_handler, .sa_flags = SA_SIGINFO, }; + + _cleanup_(sd_journal_closep) sd_journal *j = NULL; + _cleanup_free_ char *exe = NULL, *path = NULL; + _cleanup_strv_free_ char **debugger_call = NULL; bool unlink_path = false; const char *data, *fork_name; size_t len;