signal-util: generalize sigaction_nop_nocldstop

This commit is contained in:
Mike Yuan
2025-01-04 16:40:53 +01:00
parent 573e8fc217
commit bed4386e29
5 changed files with 9 additions and 17 deletions
+5
View File
@@ -302,6 +302,11 @@ const struct sigaction sigaction_default = {
.sa_flags = SA_RESTART,
};
const struct sigaction sigaction_nop_nocldstop = {
.sa_handler = nop_signal_handler,
.sa_flags = SA_NOCLDSTOP|SA_RESTART,
};
int parse_signo(const char *s, int *ret) {
int sig, r;
+1
View File
@@ -68,5 +68,6 @@ void propagate_signal(int sig, siginfo_t *siginfo);
extern const struct sigaction sigaction_ignore;
extern const struct sigaction sigaction_default;
extern const struct sigaction sigaction_nop_nocldstop;
int parse_signo(const char *s, int *ret);
+1 -6
View File
@@ -69,13 +69,8 @@ _noreturn_ static void crash(int sig, siginfo_t *siginfo, void *context) {
LOG_MESSAGE("Caught <%s>, not dumping core.", signal_to_string(sig)),
"MESSAGE_ID=" SD_MESSAGE_CRASH_NO_COREDUMP_STR);
else {
sa = (struct sigaction) {
.sa_handler = nop_signal_handler,
.sa_flags = SA_NOCLDSTOP|SA_RESTART,
};
/* We want to wait for the core process, hence let's enable SIGCHLD */
(void) sigaction(SIGCHLD, &sa, NULL);
(void) sigaction(SIGCHLD, &sigaction_nop_nocldstop, NULL);
pid = raw_clone(SIGCHLD);
if (pid < 0)
+1 -6
View File
@@ -5175,11 +5175,6 @@ static int run_container(
pid_t *pid,
int *ret) {
static const struct sigaction sa = {
.sa_handler = nop_signal_handler,
.sa_flags = SA_NOCLDSTOP|SA_RESTART,
};
_cleanup_(release_lock_file) LockFile uid_shift_lock = LOCK_FILE_INIT;
_cleanup_close_ int etc_passwd_lock = -EBADF;
_cleanup_close_pair_ int
@@ -5240,7 +5235,7 @@ static int run_container(
if (r < 0)
return log_error_errno(errno, "Failed to change the signal mask: %m");
r = sigaction(SIGCHLD, &sa, NULL);
r = sigaction(SIGCHLD, &sigaction_nop_nocldstop, NULL);
if (r < 0)
return log_error_errno(errno, "Failed to install SIGCHLD handler: %m");
@@ -571,13 +571,9 @@ static int parse_argv(int argc, char *argv[]) {
* terminated.
*/
static int ask_on_this_console(const char *tty, pid_t *ret_pid, char **arguments) {
static const struct sigaction sigchld = {
.sa_handler = nop_signal_handler,
.sa_flags = SA_NOCLDSTOP | SA_RESTART,
};
int r;
assert_se(sigaction(SIGCHLD, &sigchld, NULL) >= 0);
assert_se(sigaction(SIGCHLD, &sigaction_nop_nocldstop, NULL) >= 0);
assert_se(sigaction(SIGHUP, &sigaction_default, NULL) >= 0);
assert_se(sigprocmask_many(SIG_UNBLOCK, NULL, SIGHUP, SIGCHLD) >= 0);