[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
83/118: Call commonChildInit() before doing chroot init
From: |
Ludovic Courtès |
Subject: |
83/118: Call commonChildInit() before doing chroot init |
Date: |
Tue, 19 May 2015 14:45:50 +0000 |
civodul pushed a commit to branch nix
in repository guix.
commit b732ffd28ddf50d3150e4f276a0e8488e38eaacb
Author: Eelco Dolstra <address@hidden>
Date: Fri Aug 1 19:29:03 2014 +0200
Call commonChildInit() before doing chroot init
This ensures that daemon clients see error messages from the chroot
setup.
---
nix/libstore/build.cc | 10 ++++++----
nix/libutil/util.cc | 18 ++++++++++--------
2 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc
index 4376a83..348b3bd 100644
--- a/nix/libstore/build.cc
+++ b/nix/libstore/build.cc
@@ -374,8 +374,6 @@ void Goal::trace(const format & f)
/* Common initialisation performed in child processes. */
static void commonChildInit(Pipe & logPipe)
{
- restoreAffinity();
-
/* 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
@@ -1974,6 +1972,12 @@ void DerivationGoal::initChild()
try { /* child */
+ _writeToStderr = 0;
+
+ restoreAffinity();
+
+ commonChildInit(builderOut);
+
#if CHROOT_ENABLED
if (useChroot) {
/* Initialise the loopback interface. */
@@ -2092,8 +2096,6 @@ void DerivationGoal::initChild()
}
#endif
- commonChildInit(builderOut);
-
if (chdir(tmpDir.c_str()) == -1)
throw SysError(format("changing into `%1%'") % tmpDir);
diff --git a/nix/libutil/util.cc b/nix/libutil/util.cc
index 06c8441..b792120 100644
--- a/nix/libutil/util.cc
+++ b/nix/libutil/util.cc
@@ -466,10 +466,18 @@ void warnOnce(bool & haveWarned, const FormatOrString &
fs)
}
+static void defaultWriteToStderr(const unsigned char * buf, size_t count)
+{
+ writeFull(STDERR_FILENO, buf, count);
+}
+
+
void writeToStderr(const string & s)
{
try {
- _writeToStderr((const unsigned char *) s.data(), s.size());
+ auto p = _writeToStderr;
+ if (!p) p = defaultWriteToStderr;
+ p((const unsigned char *) s.data(), s.size());
} catch (SysError & e) {
/* Ignore failing writes to stderr if we're in an exception
handler, otherwise throw an exception. We need to ignore
@@ -481,12 +489,6 @@ void writeToStderr(const string & s)
}
-static void defaultWriteToStderr(const unsigned char * buf, size_t count)
-{
- writeFull(STDERR_FILENO, buf, count);
-}
-
-
void (*_writeToStderr) (const unsigned char * buf, size_t count) =
defaultWriteToStderr;
@@ -849,7 +851,7 @@ pid_t startProcess(std::function<void()> fun, const string
& errorPrefix)
if (pid == -1) throw SysError("unable to fork");
if (pid == 0) {
- _writeToStderr = defaultWriteToStderr;
+ _writeToStderr = 0;
try {
restoreAffinity();
fun();
- 70/118: Better fix for strcasecmp on Darwin, (continued)
- 70/118: Better fix for strcasecmp on Darwin, Ludovic Courtès, 2015/05/19
- 75/118: Merge commit 'fdee1ced43fb495d612a29e955141cdf6b9a95ba' into nix, Ludovic Courtès, 2015/05/19
- 74/118: Merge commit '8e9140cfdef9dbd1eb61e4c75c91d452ab5e4a74' into nix, Ludovic Courtès, 2015/05/19
- 73/118: startProcess: Make writing error messages from the child more robust, Ludovic Courtès, 2015/05/19
- 69/118: Bump, Ludovic Courtès, 2015/05/19
- 86/118: Add option ‘build-extra-chroot-dirs’, Ludovic Courtès, 2015/05/19
- 76/118: nix-daemon: Simplify stderr handling, Ludovic Courtès, 2015/05/19
- 77/118: nix-daemon: Less verbosity, Ludovic Courtès, 2015/05/19
- 90/118: Remove unnecessary call to addTempRoot(), Ludovic Courtès, 2015/05/19
- 88/118: Move some options out of globals, Ludovic Courtès, 2015/05/19
- 83/118: Call commonChildInit() before doing chroot init,
Ludovic Courtès <=
- 84/118: Remove ugly hack for detecting build environment setup errors, Ludovic Courtès, 2015/05/19
- 85/118: Get rid of "killing <pid>" message for unused build hooks, Ludovic Courtès, 2015/05/19
- 93/118: Reduce verbosity, Ludovic Courtès, 2015/05/19
- 92/118: Propagate remote timeouts properly, Ludovic Courtès, 2015/05/19
- 87/118: Refactor, Ludovic Courtès, 2015/05/19
- 79/118: Allow regular files as GC roots, Ludovic Courtès, 2015/05/19
- 89/118: Doh, Ludovic Courtès, 2015/05/19
- 78/118: Remove some dead code, Ludovic Courtès, 2015/05/19
- 82/118: Eliminate redundant copy, Ludovic Courtès, 2015/05/19
- 95/118: Make hook shutdown more reliable, Ludovic Courtès, 2015/05/19