about summary refs log tree commit diff
path: root/src/libutil
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-12-03T02·08+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-12-03T02·08+0000
commit7951c3c5460324c652d42f5f92bcae44e0a0b9c7 (patch)
treeda8595f52e710af3313a177cc73a1a1b0cfffe87 /src/libutil
parent714fa24cfb5afeb144549e0cc4808cc2a1c459cf (diff)
* Some hackery to propagate the worker's stderr and exceptions to the
  client.

Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/util.cc11
-rw-r--r--src/libutil/util.hh2
2 files changed, 12 insertions, 1 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 6d96310dadbb..4460d95b8e42 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -437,7 +437,7 @@ void printMsg_(Verbosity level, const format & f)
     else if (logType == ltEscapes && level != lvlInfo)
         prefix = "\033[" + escVerbosity(level) + "s";
     string s = (format("%1%%2%\n") % prefix % f.str()).str();
-    writeFull(STDERR_FILENO, (const unsigned char *) s.c_str(), s.size());
+    writeToStderr((const unsigned char *) s.c_str(), s.size());
 }
 
 
@@ -450,6 +450,15 @@ void warnOnce(bool & haveWarned, const format & f)
 }
 
 
+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;
+
+
 void readFull(int fd, unsigned char * buf, size_t count)
 {
     while (count) {
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index d49067dfe2c7..0d39ffee9eae 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -131,6 +131,8 @@ void printMsg_(Verbosity level, const format & f);
 
 void warnOnce(bool & haveWarned, const format & f);
 
+extern void (*writeToStderr) (const unsigned char * buf, size_t count);
+
 
 /* Wrappers arount read()/write() that read/write exactly the
    requested number of bytes. */