From 40e95a2e3055acbe398646b3cccf6cd573876ff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophane=20Hufschmitt?= Date: Mon, 11 Apr 2022 10:20:37 +0200 Subject: [PATCH] Fix the build on darwin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `MSG_NOSIGNAL` doesn’t exist on darwin, so globally ignore the `SIGPIPE` signal instead. --- src/nix-find-roots/main.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/nix-find-roots/main.cc b/src/nix-find-roots/main.cc index fd9f2366f..c319759a7 100644 --- a/src/nix-find-roots/main.cc +++ b/src/nix-find-roots/main.cc @@ -5,6 +5,7 @@ #include #include #include +#include using namespace nix::roots_tracer; @@ -128,6 +129,9 @@ int main(int argc, char * * argv) throw Error("cannot listen on socket " + opts.socketPath.string()); } + // Ignore SIGPIPE so that an interrupted connection doesn’t stop the daemon + signal(SIGPIPE, SIG_IGN); + while (1) { struct sockaddr_un remoteAddr; socklen_t remoteAddrLen = sizeof(remoteAddr); @@ -145,7 +149,7 @@ int main(int argc, char * * argv) opts.log("accepted connection"); auto printToSocket = [&](std::string_view s) { - send(remoteSocket, s.data(), s.size(), MSG_NOSIGNAL); + send(remoteSocket, s.data(), s.size(), 0); }; auto traceResult = traceStaticRoots(opts, standardRoots);