mirror of
https://github.com/NixOS/nix.git
synced 2025-11-15 06:52:43 +01:00
Split out commonChildInit
This commit is contained in:
parent
725488b892
commit
aef44cbaa9
3 changed files with 31 additions and 29 deletions
|
|
@ -456,35 +456,6 @@ void Goal::trace(const FormatOrString & fs)
|
|||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/* Common initialisation performed in child processes. */
|
||||
static void commonChildInit(Pipe & logPipe)
|
||||
{
|
||||
restoreSignals();
|
||||
|
||||
/* Put the child in a separate session (and thus a separate
|
||||
process group) so that it has no controlling terminal (meaning
|
||||
that e.g. ssh cannot open /dev/tty) and it doesn't receive
|
||||
terminal signals. */
|
||||
if (setsid() == -1)
|
||||
throw SysError("creating a new session");
|
||||
|
||||
/* Dup the write side of the logger pipe into stderr. */
|
||||
if (dup2(logPipe.writeSide.get(), STDERR_FILENO) == -1)
|
||||
throw SysError("cannot pipe standard error into log file");
|
||||
|
||||
/* Dup stderr to stdout. */
|
||||
if (dup2(STDERR_FILENO, STDOUT_FILENO) == -1)
|
||||
throw SysError("cannot dup stderr into stdout");
|
||||
|
||||
/* Reroute stdin to /dev/null. */
|
||||
int fdDevNull = open(pathNullDevice.c_str(), O_RDWR);
|
||||
if (fdDevNull == -1)
|
||||
throw SysError("cannot open '%1%'", pathNullDevice);
|
||||
if (dup2(fdDevNull, STDIN_FILENO) == -1)
|
||||
throw SysError("cannot dup null device into stdin");
|
||||
close(fdDevNull);
|
||||
}
|
||||
|
||||
void handleDiffHook(
|
||||
uid_t uid, uid_t gid,
|
||||
const Path & tryA, const Path & tryB,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue