From: Eric Cooper <ecc@cmu.edu>
Date: Thu, 24 Feb 2011 22:43:13 -0500
Subject: call send with MSG_NOSIGNAL to avoid SIGPIPE


Signed-off-by: Eric Cooper <ecc@cmu.edu>
---
 syslog.ml |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/syslog.ml b/syslog.ml
index c6c66f4..80e179c 100644
--- a/syslog.ml
+++ b/syslog.ml
@@ -191,14 +191,11 @@ let protected_write loginfo str =
     (try open_connection loginfo with _ -> ());
     if List.mem `LOG_CONS loginfo.flags then log_console str
   in
-  let prev = Sys.signal Sys.sigpipe (Sys.Signal_handle fallback) in
   try
-    ignore (write loginfo.fd str 0 (String.length str));
-    Sys.set_signal Sys.sigpipe prev
+    ignore (Aux.send loginfo.fd str 0 (String.length str) [Aux.MSG_NOSIGNAL])
   with Unix_error (_, _, _) ->
     (* on error, attempt to reconnect *)
-    fallback ();
-    Sys.set_signal Sys.sigpipe prev
+    fallback ()
 
 let syslog ?fac loginfo lev str =
   let msg = Buffer.create 64 in
-- 
