Skip to contentSkip to conversation

generator: fix file descriptor leak

PATCH New Topi Miettinen 1 participant 1 message Dec 23, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 generator: fix file descriptor leak

Set close-on-exec flag for kmsg file descriptor, so that _error() can be used in case of execve() failure.

---
 scripts/lvm2_activation_generator_systemd_red_hat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/lvm2_activation_generator_systemd_red_hat.c +1 -1
index 0f4ac8da2..e137aaf89 100644
@@ -23,7 +23,7 @@ static int _kmsg_fd;
 static void _log_init(void)
 {
        // failing is harmless
-       _kmsg_fd = open(KMSG_DEV_PATH, O_WRONLY | O_NOCTTY);
+       _kmsg_fd = open(KMSG_DEV_PATH, O_WRONLY | O_NOCTTY | O_CLOEXEC);
 }
 
 static void _log_exit(void)
Signature · 1 line
2.24.0