Package: syslog-ocaml / 1.4-7

0003-call-send-with-MSG_NOSIGNAL-to-avoid-SIGPIPE.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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 file 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