From: Peter van Dijk Date: Fri, 24 Jun 2022 11:02:07 +0000 (+0200) Subject: dnsdist newThread(): mask SIGTERM X-Git-Tag: auth-4.8.0-alpha0~42^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F11722%2Fhead;p=thirdparty%2Fpdns.git dnsdist newThread(): mask SIGTERM --- diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 157e34e37a..ec50b3b4b1 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -270,6 +270,15 @@ void checkParameterBound(const std::string& parameter, uint64_t value, size_t ma static void LuaThread(const std::string code) { LuaContext l; + + // mask SIGTERM on threads so the signal always comes to dnsdist itself + sigset_t blockSignals; + + sigemptyset(&blockSignals); + sigaddset(&blockSignals, SIGTERM); + + pthread_sigmask(SIG_BLOCK, &blockSignals, nullptr); + // submitToMainThread is camelcased, threadmessage is not. // This follows our tradition of hooks we call being lowercased but functions the user can call being camelcased. l.writeFunction("submitToMainThread", [](std::string cmd, LuaAssociativeTable data) { @@ -2873,6 +2882,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) return; } std::thread newThread(LuaThread, code); + newThread.detach(); });