[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
107/376: Call commonChildInit() before doing chroot init
From: |
Ludovic Courtès |
Subject: |
107/376: Call commonChildInit() before doing chroot init |
Date: |
Wed, 28 Jan 2015 22:04:22 +0000 |
civodul pushed a commit to tag 1.8
in repository guix.
commit 4c4b219c07c08c709c94af6f3fe1f25dea0563a0
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.
---
src/libstore/build.cc | 10 ++++++----
src/libutil/util.cc | 18 ++++++++++--------
2 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 479bc4a..03aea8b 100644
--- a/src/libstore/build.cc
+++ b/src/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
@@ -1962,6 +1960,12 @@ void DerivationGoal::initChild()
try { /* child */
+ _writeToStderr = 0;
+
+ restoreAffinity();
+
+ commonChildInit(builderOut);
+
#if CHROOT_ENABLED
if (useChroot) {
/* Initialise the loopback interface. */
@@ -2080,8 +2084,6 @@ void DerivationGoal::initChild()
}
#endif
- commonChildInit(builderOut);
-
if (chdir(tmpDir.c_str()) == -1)
throw SysError(format("changing into `%1%'") % tmpDir);
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 595e724..44087d5 100644
--- a/src/libutil/util.cc
+++ b/src/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();
- 92/376: Fix NIX_SSHOPTS, (continued)
- 92/376: Fix NIX_SSHOPTS, Ludovic Courtès, 2015/01/28
- 103/376: Allow regular files as GC roots, Ludovic Courtès, 2015/01/28
- 94/376: nix-copy-closure: Drop --bzip2, --xz, --show-progress, Ludovic Courtès, 2015/01/28
- 84/376: Use pthread_cancel instead of a signal, Ludovic Courtès, 2015/01/28
- 102/376: Restore default SIGPIPE handler before invoking ‘man’, Ludovic Courtès, 2015/01/28
- 98/376: nix-profile.sh: Set $SSL_CERT_FILE, Ludovic Courtès, 2015/01/28
- 96/376: nix-daemon: Pass on the user's $SSH_AUTH_SOCK to the SSH substituter, Ludovic Courtès, 2015/01/28
- 101/376: make clean: Remove Makefile.config, Ludovic Courtès, 2015/01/28
- 105/376: findRoots(): Prevent a call to lstat(), Ludovic Courtès, 2015/01/28
- 108/376: Remove ugly hack for detecting build environment setup errors, Ludovic Courtès, 2015/01/28
- 107/376: Call commonChildInit() before doing chroot init,
Ludovic Courtès <=
- 104/376: Make readDirectory() return inode / file type, Ludovic Courtès, 2015/01/28
- 106/376: Eliminate redundant copy, Ludovic Courtès, 2015/01/28
- 110/376: Make chroot builds easier to set up, Ludovic Courtès, 2015/01/28
- 109/376: Speed up nix-shell, Ludovic Courtès, 2015/01/28
- 121/376: nix-install-package: Use extra-binary-caches, Ludovic Courtès, 2015/01/28
- 119/376: Add support for order-only dependencies, Ludovic Courtès, 2015/01/28
- 118/376: install-nix-from-closure.sh: Use https channel if possible, Ludovic Courtès, 2015/01/28
- 114/376: Refactor, Ludovic Courtès, 2015/01/28
- 117/376: Remove unnecessary call to addTempRoot(), Ludovic Courtès, 2015/01/28
- 115/376: Move some options out of globals, Ludovic Courtès, 2015/01/28