[bug#75810,v6,02/16] daemon: Close the read end of the logging pipe.

Message ID b4f08920874bad9386a1bdb390859c3c78be5aa1.1742230219.git.ludo@gnu.org
State New
Headers
Series Rootless guix-daemon |

Commit Message

Ludovic Courtès March 17, 2025, 5:02 p.m. UTC
  * nix/libutil/util.cc (commonChildInit): Close ‘logPipe.readSide’.

Reported-by: Reepca Russelstein <reepca@russelstein.xyz>
Change-Id: Ia9e48d1afb85d7af52770e016f2b6832792044dd
---
 nix/libutil/util.cc | 3 +++
 1 file changed, 3 insertions(+)
  

Patch

diff --git a/nix/libutil/util.cc b/nix/libutil/util.cc
index eb2d16e1cc..56f116046c 100644
--- a/nix/libutil/util.cc
+++ b/nix/libutil/util.cc
@@ -1279,6 +1279,9 @@  void commonChildInit(Pipe & logPipe)
     if (setsid() == -1)
         throw SysError(format("creating a new session"));
 
+    /* Close the read end so only the parent holds a reference to it.  */
+    logPipe.readSide.close();
+
     /* Dup the write side of the logger pipe into stderr. */
     if (dup2(logPipe.writeSide, STDERR_FILENO) == -1)
         throw SysError("cannot pipe standard error into log file");