]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
pager: let's create pager fds with O_CLOEXEC first 6810/head
authorLennart Poettering <lennart@poettering.net>
Wed, 13 Sep 2017 08:35:28 +0000 (10:35 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 13 Sep 2017 08:37:52 +0000 (10:37 +0200)
We make copies (without O_CLOEXEC) of the fds anyway before using them,
hence let's be safe and create them with O_CLOEXEC first, so that we
don't run into issues should pager_open() be called in a threaded
environment where another thread fork()s at the wrong time and ends up
with fds not marked O_CLOEXEC.

src/shared/pager.c

index ad48652527865e4f934c360691312b9cef0cd6ef..0661ff0bb9b21e9b748039182b7fc1ff763ee931 100644 (file)
@@ -84,7 +84,7 @@ int pager_open(bool no_pager, bool jump_to_end) {
          * pager so that we get the value from the actual tty */
         (void) columns();
 
-        if (pipe(fd) < 0)
+        if (pipe2(fd, O_CLOEXEC) < 0)
                 return log_error_errno(errno, "Failed to create pager pipe: %m");
 
         parent_pid = getpid_cached();