From e962501ce2bf7367b9a3992ab6e6a6d5eefb3aca Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Sun, 21 Apr 2024 21:11:14 +0200 Subject: [PATCH 1/2] Fix the FD_CLOEXEC bit FD_CLOEXEC is not a bit position. It's a bit mask already. See the definition in the kernel: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/fcntl.h and the use of that constant in: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/fcntl.c The current code in sd-notify is a no-op. Bit 1 is not looked at by the kernel. sd-notify does not touch bit 0. Fix this by changing the mask. --- src/ffi.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ffi.rs b/src/ffi.rs index 5101004..4c111a7 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -5,6 +5,6 @@ extern "C" { pub const F_GETFD: i32 = 1; pub const F_SETFD: i32 = 2; -pub const FD_CLOEXEC: i32 = 2; +pub const FD_CLOEXEC: i32 = 1; pub const EBADF: i32 = 9; From a04e6fd77b1d1cb8eaa817eac28f53baf07b64be Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Mon, 22 Apr 2024 17:23:35 +0200 Subject: [PATCH 2/2] ChangeLog: Add FD_CLOEXEC change --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f65ebda..e6d56d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [0.4.2] - 2024-04-22 + +### Changed + +- `FD_CLOEXEC` bit mask definition fixed. The wrong definition effectively lead to `close-on-exec` flag not being set for all `listen_fds`. + ## [0.4.1] - 2022-08-31 ### Changed