summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-12-19 06:15:07 +0100
committerLuca Boccassi <luca.boccassi@gmail.com>2023-12-23 00:32:48 +0100
commit60d52f219eec0fbf300ee7bc7ee96da64f9e03b9 (patch)
tree3b874146a7c57bca44cad5bc51fb5f7ba0c9dfb9
parentMerge pull request #30590 from yuwata/backlight-cleanups (diff)
downloadsystemd-60d52f219eec0fbf300ee7bc7ee96da64f9e03b9.tar.xz
systemd-60d52f219eec0fbf300ee7bc7ee96da64f9e03b9.zip
udev: use SD_EVENT_SIGNAL_PROCMASK
-rw-r--r--src/udev/udev-manager.c13
-rw-r--r--src/udev/udev-worker.c4
2 files changed, 8 insertions, 9 deletions
diff --git a/src/udev/udev-manager.c b/src/udev/udev-manager.c
index 8077e51055..abba6958ab 100644
--- a/src/udev/udev-manager.c
+++ b/src/udev/udev-manager.c
@@ -1260,22 +1260,22 @@ int manager_main(Manager *manager) {
udev_watch_restore(manager->inotify_fd);
- /* block and listen to all signals on signalfd */
- assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, SIGHUP, SIGCHLD, SIGRTMIN+18, -1) >= 0);
+ /* block SIGCHLD for listening child events. */
+ assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD, -1) >= 0);
r = sd_event_default(&manager->event);
if (r < 0)
return log_error_errno(r, "Failed to allocate event loop: %m");
- r = sd_event_add_signal(manager->event, NULL, SIGINT, on_sigterm, manager);
+ r = sd_event_add_signal(manager->event, NULL, SIGINT | SD_EVENT_SIGNAL_PROCMASK, on_sigterm, manager);
if (r < 0)
return log_error_errno(r, "Failed to create SIGINT event source: %m");
- r = sd_event_add_signal(manager->event, NULL, SIGTERM, on_sigterm, manager);
+ r = sd_event_add_signal(manager->event, NULL, SIGTERM | SD_EVENT_SIGNAL_PROCMASK, on_sigterm, manager);
if (r < 0)
return log_error_errno(r, "Failed to create SIGTERM event source: %m");
- r = sd_event_add_signal(manager->event, NULL, SIGHUP, on_sighup, manager);
+ r = sd_event_add_signal(manager->event, NULL, SIGHUP | SD_EVENT_SIGNAL_PROCMASK, on_sighup, manager);
if (r < 0)
return log_error_errno(r, "Failed to create SIGHUP event source: %m");
@@ -1325,7 +1325,8 @@ int manager_main(Manager *manager) {
log_full_errno(ERRNO_IS_NOT_SUPPORTED(r) || ERRNO_IS_PRIVILEGE(r) || (r == -EHOSTDOWN) ? LOG_DEBUG : LOG_WARNING, r,
"Failed to allocate memory pressure watch, ignoring: %m");
- r = sd_event_add_signal(manager->event, &manager->memory_pressure_event_source, SIGRTMIN+18, sigrtmin18_handler, NULL);
+ r = sd_event_add_signal(manager->event, &manager->memory_pressure_event_source,
+ (SIGRTMIN+18) | SD_EVENT_SIGNAL_PROCMASK, sigrtmin18_handler, NULL);
if (r < 0)
return log_error_errno(r, "Failed to allocate SIGRTMIN+18 event source, ignoring: %m");
diff --git a/src/udev/udev-worker.c b/src/udev/udev-worker.c
index 53722b21bd..2dc7bd0820 100644
--- a/src/udev/udev-worker.c
+++ b/src/udev/udev-worker.c
@@ -318,8 +318,6 @@ int udev_worker_main(UdevWorker *worker, sd_device *dev) {
DEVICE_TRACE_POINT(worker_spawned, dev, getpid_cached());
- assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, -1) >= 0);
-
/* Reset OOM score, we only protect the main daemon. */
r = set_oom_score_adjust(0);
if (r < 0)
@@ -329,7 +327,7 @@ int udev_worker_main(UdevWorker *worker, sd_device *dev) {
if (r < 0)
return log_error_errno(r, "Failed to allocate event loop: %m");
- r = sd_event_add_signal(worker->event, NULL, SIGTERM, NULL, NULL);
+ r = sd_event_add_signal(worker->event, NULL, SIGTERM | SD_EVENT_SIGNAL_PROCMASK, NULL, NULL);
if (r < 0)
return log_error_errno(r, "Failed to set SIGTERM event: %m");