summaryrefslogtreecommitdiffstats
path: root/src/udev
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-11-02 11:04:36 +0100
committerLennart Poettering <lennart@poettering.net>2023-11-02 14:09:23 +0100
commite9ccae31355b8d4fd7496b0548470c8c977897d8 (patch)
tree13c5f4246df81fa08c396303b14acf15ccdcc2a5 /src/udev
parentfd-util: add new FORMAT_PROC_PID_FD_PATH() helper (diff)
downloadsystemd-e9ccae31355b8d4fd7496b0548470c8c977897d8.tar.xz
systemd-e9ccae31355b8d4fd7496b0548470c8c977897d8.zip
process-util: add new FORK_DEATHSIG_SIGKILL flag, rename FORK_DEATHSIG → FORK_DEATHSIG_SIGTERM
Sometimes it makes sense to hard kill a client if we die. Let's hence add a third FORK_DEATHSIG flag for this purpose: FORK_DEATHSIG_SIGKILL. To make things less confusing this also renames FORK_DEATHSIG to FORK_DEATHSIG_SIGTERM to make clear it sends SIGTERM. We already had FORK_DEATHSIG_SIGINT, hence this makes things nicely symmetric. A bunch of users are switched over for FORK_DEATHSIG_SIGKILL where we know it's safe to abort things abruptly. This should make some kernel cases more robust, since we cannot get confused by signal masks or such. While we are at it, also fix a bunch of bugs where we didn't take FORK_DEATHSIG_SIGINT into account in safe_fork()
Diffstat (limited to 'src/udev')
-rw-r--r--src/udev/udev-manager.c2
-rw-r--r--src/udev/udev-spawn.c2
-rw-r--r--src/udev/udevadm-lock.c4
3 files changed, 4 insertions, 4 deletions
diff --git a/src/udev/udev-manager.c b/src/udev/udev-manager.c
index 697dc2f14f..aca241c0c9 100644
--- a/src/udev/udev-manager.c
+++ b/src/udev/udev-manager.c
@@ -381,7 +381,7 @@ static int worker_spawn(Manager *manager, Event *event) {
if (r < 0)
return log_error_errno(r, "Worker: Failed to enable receiving of device: %m");
- r = safe_fork("(udev-worker)", FORK_DEATHSIG, &pid);
+ r = safe_fork("(udev-worker)", FORK_DEATHSIG_SIGTERM, &pid);
if (r < 0) {
event->state = EVENT_QUEUED;
return log_error_errno(r, "Failed to fork() worker: %m");
diff --git a/src/udev/udev-spawn.c b/src/udev/udev-spawn.c
index 9501013d1c..1d0b8548e3 100644
--- a/src/udev/udev-spawn.c
+++ b/src/udev/udev-spawn.c
@@ -280,7 +280,7 @@ int udev_event_spawn(
r = safe_fork_full("(spawn)",
(int[]) { -EBADF, outpipe[WRITE_END], errpipe[WRITE_END] },
NULL, 0,
- FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_DEATHSIG|FORK_REARRANGE_STDIO|FORK_LOG|FORK_RLIMIT_NOFILE_SAFE,
+ FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_DEATHSIG_SIGTERM|FORK_REARRANGE_STDIO|FORK_LOG|FORK_RLIMIT_NOFILE_SAFE,
&pid);
if (r < 0)
return log_device_error_errno(event->dev, r,
diff --git a/src/udev/udevadm-lock.c b/src/udev/udevadm-lock.c
index 89d7d256d2..8993cc4571 100644
--- a/src/udev/udevadm-lock.c
+++ b/src/udev/udevadm-lock.c
@@ -226,7 +226,7 @@ static int lock_device(
BLOCK_SIGNALS(SIGCHLD);
- r = safe_fork("(timed-flock)", FORK_DEATHSIG|FORK_LOG, &flock_pid);
+ r = safe_fork("(timed-flock)", FORK_DEATHSIG_SIGKILL|FORK_LOG, &flock_pid);
if (r < 0)
return r;
if (r == 0) {
@@ -349,7 +349,7 @@ int lock_main(int argc, char *argv[], void *userdata) {
/* Ignore SIGINT and allow the forked process to receive it */
(void) ignore_signals(SIGINT);
- r = safe_fork("(lock)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_CLOSE_ALL_FDS|FORK_RLIMIT_NOFILE_SAFE|FORK_LOG, &pid);
+ r = safe_fork("(lock)", FORK_RESET_SIGNALS|FORK_DEATHSIG_SIGTERM|FORK_CLOSE_ALL_FDS|FORK_RLIMIT_NOFILE_SAFE|FORK_LOG, &pid);
if (r < 0)
return r;
if (r == 0) {