1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-12 13:36:02 +01:00

Simplify commonChildInit()

(cherry picked from commit 19326ac297)
This commit is contained in:
Eelco Dolstra 2023-03-14 18:58:12 +01:00 committed by John Ericson
parent 3468fec15b
commit 3a82f6a117

View file

@ -442,7 +442,7 @@ void Goal::trace(const FormatOrString & fs)
/* Common initialisation performed in child processes. */ /* Common initialisation performed in child processes. */
static void commonChildInit(Pipe & logPipe) static void commonChildInit(int stderrFd)
{ {
restoreSignals(); restoreSignals();
@ -454,7 +454,7 @@ static void commonChildInit(Pipe & logPipe)
throw SysError(format("creating a new session")); throw SysError(format("creating a new session"));
/* Dup the write side of the logger pipe into stderr. */ /* Dup the write side of the logger pipe into stderr. */
if (dup2(logPipe.writeSide.get(), STDERR_FILENO) == -1) if (dup2(stderrFd, STDERR_FILENO) == -1)
throw SysError("cannot pipe standard error into log file"); throw SysError("cannot pipe standard error into log file");
/* Dup stderr to stdout. */ /* Dup stderr to stdout. */
@ -678,7 +678,7 @@ HookInstance::HookInstance()
/* Fork the hook. */ /* Fork the hook. */
pid = startProcess([&]() { pid = startProcess([&]() {
commonChildInit(fromHook); commonChildInit(fromHook.writeSide.get());
if (chdir("/") == -1) throw SysError("changing into /"); if (chdir("/") == -1) throw SysError("changing into /");
@ -2736,7 +2736,7 @@ void DerivationGoal::runChild()
try { /* child */ try { /* child */
commonChildInit(builderOut); commonChildInit(builderOut.writeSide.get());
try { try {
setupSeccomp(); setupSeccomp();