From abc4b1ffafe4eb59707cdf6b5c84058e7fd15277 Mon Sep 17 00:00:00 2001 From: funwithcthulhu <29905917+funwithcthulhu@users.noreply.github.com> Date: Thu, 21 May 2026 20:53:59 -0700 Subject: [PATCH] Ignore SIGPIPE when serving --- src/http/http.ml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/http/http.ml b/src/http/http.ml index 6cce597a..ced46318 100644 --- a/src/http/http.ml +++ b/src/http/http.ml @@ -687,6 +687,10 @@ let on_termination_signal () = ignore (Lwt_unix.on_signal Sys.sigint (fun _ -> Lwt.wakeup_later int_resolve ())); Lwt.pick [term_promise; int_promise] +let ignore_sigpipe () = + if Sys.unix then + Sys.(set_signal sigpipe Signal_ignore) + let network ~port ~socket_path = match socket_path with | None -> `Inet port @@ -704,6 +708,8 @@ let serve ?(builtins = true) user's_dream_handler = + ignore_sigpipe (); + serve_with_maybe_https "serve" ~interface @@ -734,9 +740,7 @@ let run ?adjust_terminal user's_dream_handler = - let () = if Sys.unix then - Sys.(set_signal sigpipe Signal_ignore) - in + ignore_sigpipe (); let log = Log.convenience_log in