From 83e5672f908e02055e21cc8e40703007efb7bf7f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 11 Jul 2024 11:43:40 +0200 Subject: [PATCH] exec-invoke: save original stdin/stdout with O_CLOEXEC set We turn off the flag anyway when we install them back as stdin/stdout later (via dup2()). let's hence follow our usual rules, and turn on O_CLOEXEC. --- src/core/exec-invoke.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/exec-invoke.c b/src/core/exec-invoke.c index 9489fc23096..5a47c336c0b 100644 --- a/src/core/exec-invoke.c +++ b/src/core/exec-invoke.c @@ -659,11 +659,11 @@ static int setup_confirm_stdio( assert(ret_saved_stdin); assert(ret_saved_stdout); - saved_stdin = fcntl(STDIN_FILENO, F_DUPFD, 3); + saved_stdin = fcntl(STDIN_FILENO, F_DUPFD_CLOEXEC, 3); if (saved_stdin < 0) return -errno; - saved_stdout = fcntl(STDOUT_FILENO, F_DUPFD, 3); + saved_stdout = fcntl(STDOUT_FILENO, F_DUPFD_CLOEXEC, 3); if (saved_stdout < 0) return -errno; -- 2.47.3