From: Lennart Poettering Date: Thu, 11 Jul 2024 09:43:40 +0000 (+0200) Subject: exec-invoke: save original stdin/stdout with O_CLOEXEC set X-Git-Tag: v257-rc1~873^2~14 X-Git-Url: http://git-history.diyao.me/?a=commitdiff_plain;h=83e5672f908e02055e21cc8e40703007efb7bf7f;p=systemd%2F.git 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. --- diff --git a/src/core/exec-invoke.c b/src/core/exec-invoke.c index 9489fc2309..5a47c336c0 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;