From 9cb50f01b2cd8df49d55d93dbfb413fc6360c230 Mon Sep 17 00:00:00 2001 From: Benjamin Canou Date: Mon, 4 Dec 2017 15:46:26 +0100 Subject: [PATCH] P2P: ignore spurious SIGPIPE signals --- lib_node_p2p/p2p_io_scheduler.ml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib_node_p2p/p2p_io_scheduler.ml b/lib_node_p2p/p2p_io_scheduler.ml index 93bdb6f9a..8b08312bc 100644 --- a/lib_node_p2p/p2p_io_scheduler.ml +++ b/lib_node_p2p/p2p_io_scheduler.ml @@ -9,6 +9,14 @@ (* TODO decide whether we need to preallocate buffers or not. *) +let () = + (* Otherwise some writes trigger a SIGPIPE instead of raising an + Lwt_unit exception. In the node, this is already done by + Cohttp, so this is only useful when using the P2P layer as a + stand alone library. *) + if Sys.os_type <> "Win32" then + Sys.(set_signal sigpipe Signal_ignore) + open P2p_types include Logging.Make (struct let name = "p2p.io-scheduler" end)