From d98755b0c291fed59c71957ac8dbe4ee94e58b10 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Wed, 14 Mar 2018 21:39:01 -0500 Subject: [PATCH] nix-daemon: preserve errno in signal handler (thanks tsan) --- src/nix-daemon/nix-daemon.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/nix-daemon/nix-daemon.cc b/src/nix-daemon/nix-daemon.cc index 890bffa19..30e2b5455 100644 --- a/src/nix-daemon/nix-daemon.cc +++ b/src/nix-daemon/nix-daemon.cc @@ -816,8 +816,11 @@ static void processConnection(bool trusted) static void sigChldHandler(int sigNo) { + // Ensure we don't modify errno of whatever we've interrupted + auto saved_errno = errno; /* Reap all dead children. */ while (waitpid(-1, 0, WNOHANG) > 0) ; + errno = saved_errno; }