From f540fcd7a4f90f293d4ef604203264e9a3a92e13 Mon Sep 17 00:00:00 2001 From: Liam Stevenson Date: Thu, 4 Apr 2024 13:54:38 -0400 Subject: [PATCH 1/4] Ignore SIGPIPE in the Merlin server process --- src/frontend/ocamlmerlin/ocamlmerlin_server.ml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/frontend/ocamlmerlin/ocamlmerlin_server.ml b/src/frontend/ocamlmerlin/ocamlmerlin_server.ml index 0cc4cbc29b..e05f444311 100644 --- a/src/frontend/ocamlmerlin/ocamlmerlin_server.ml +++ b/src/frontend/ocamlmerlin/ocamlmerlin_server.ml @@ -64,6 +64,8 @@ module Server = struct | None -> Logger.log ~section:"server" ~title:"cannot setup listener" "" | Some server -> + (* If the client closes its connection, don't let it kill us with a SIGPIPE. *) + let (_ : Sys.signal_behavior) = Sys.signal Sys.sigpipe Sys.Signal_ignore in loop (File_id.get Sys.executable_name) server; Os_ipc.server_close server end From 9df2ed8e76b4019c188d29f95a158ef77035f5c2 Mon Sep 17 00:00:00 2001 From: Liam Stevenson Date: Fri, 5 Apr 2024 13:29:42 -0400 Subject: [PATCH 2/4] Ignore SIGPIPE only on unix --- src/frontend/ocamlmerlin/ocamlmerlin_server.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/ocamlmerlin/ocamlmerlin_server.ml b/src/frontend/ocamlmerlin/ocamlmerlin_server.ml index e05f444311..a11dcb697b 100644 --- a/src/frontend/ocamlmerlin/ocamlmerlin_server.ml +++ b/src/frontend/ocamlmerlin/ocamlmerlin_server.ml @@ -65,7 +65,7 @@ module Server = struct Logger.log ~section:"server" ~title:"cannot setup listener" "" | Some server -> (* If the client closes its connection, don't let it kill us with a SIGPIPE. *) - let (_ : Sys.signal_behavior) = Sys.signal Sys.sigpipe Sys.Signal_ignore in + if Sys.unix then ignore @@ Sys.signal Sys.sigpipe Sys.Signal_ignore; loop (File_id.get Sys.executable_name) server; Os_ipc.server_close server end From a3a3181f0b7b9ba2c99d062b55969a4737c1e947 Mon Sep 17 00:00:00 2001 From: Liam Stevenson Date: Mon, 8 Apr 2024 11:43:17 -0400 Subject: [PATCH 3/4] Update changelog --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index f522320c42..901ca0b628 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,7 @@ merlin NEXT_VERSION - destruct: Removal of residual patterns (#1737, fixes #1560) - Do not erase fields' names when destructing punned record fields (#1734, fixes #1661) + - Ignore SIGPIPE in the Merlin server process (#1746) merlin 4.14 =========== From 4b4d637940f1bef6be9c7719f1436f5b30df7d62 Mon Sep 17 00:00:00 2001 From: Liam Stevenson Date: Thu, 18 Apr 2024 18:10:37 +0100 Subject: [PATCH 4/4] Use set_signal to avoid ignore --- src/frontend/ocamlmerlin/ocamlmerlin_server.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/ocamlmerlin/ocamlmerlin_server.ml b/src/frontend/ocamlmerlin/ocamlmerlin_server.ml index a11dcb697b..56b967a9a4 100644 --- a/src/frontend/ocamlmerlin/ocamlmerlin_server.ml +++ b/src/frontend/ocamlmerlin/ocamlmerlin_server.ml @@ -65,7 +65,7 @@ module Server = struct Logger.log ~section:"server" ~title:"cannot setup listener" "" | Some server -> (* If the client closes its connection, don't let it kill us with a SIGPIPE. *) - if Sys.unix then ignore @@ Sys.signal Sys.sigpipe Sys.Signal_ignore; + if Sys.unix then Sys.set_signal Sys.sigpipe Sys.Signal_ignore; loop (File_id.get Sys.executable_name) server; Os_ipc.server_close server end