tree-wide: make sigactions static const

This commit is contained in:
Mike Yuan
2025-01-04 14:49:14 +01:00
parent bed4386e29
commit 5734893f82
4 changed files with 14 additions and 14 deletions

View File

@@ -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,
};

View File

@@ -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...");

View File

@@ -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,
};

View File

@@ -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;