about summary refs log tree commit diff
path: root/src/libutil/util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil/util.cc')
-rw-r--r--src/libutil/util.cc20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index ae5af249203e..d61b35bdfbe0 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -444,7 +444,11 @@ void warnOnce(bool & haveWarned, const format & f)
 
 static void defaultWriteToStderr(const unsigned char * buf, size_t count)
 {
-    writeFull(STDERR_FILENO, buf, count);
+    try {
+        writeFull(STDERR_FILENO, buf, count);
+    } catch (SysError & e) {
+        /* ignore EPIPE etc. */
+    }
 }
 
 
@@ -545,8 +549,8 @@ AutoCloseFD::~AutoCloseFD()
 {
     try {
         close();
-    } catch (Error & e) {
-        printMsg(lvlError, format("error (ignored): %1%") % e.msg());
+    } catch (...) {
+        ignoreException();
     }
 }
 
@@ -968,5 +972,15 @@ bool string2Int(const string & s, int & n)
     return str && str.get() == EOF;
 }
 
+
+void ignoreException()
+{
+    try {
+        throw;
+    } catch (std::exception & e) {
+        printMsg(lvlError, format("error (ignored): %1%") % e.what());
+    }
+}
+
  
 }