diff --git a/nixd/include/nixd/Eval/AttrSetClient.h b/nixd/include/nixd/Eval/AttrSetClient.h index d1edbc794..11931d9b4 100644 --- a/nixd/include/nixd/Eval/AttrSetClient.h +++ b/nixd/include/nixd/Eval/AttrSetClient.h @@ -32,6 +32,8 @@ class AttrSetClient : public lspserver::LSPServer { lspserver::Callback Reply)> OptionComplete; + llvm::unique_function Exit; + public: AttrSetClient(std::unique_ptr In, std::unique_ptr Out); @@ -63,6 +65,8 @@ class AttrSetClient : public lspserver::LSPServer { OptionComplete(Params, std::move(Reply)); } + void exit() { Exit(nullptr); } + /// Get executable path for launching the server. /// \returns null terminated string. static const char *getExe(); @@ -78,6 +82,7 @@ class AttrSetClientProc { /// \returns nullptr if it has been dead. AttrSetClient *client(); ~AttrSetClientProc() { + Client.exit(); Client.closeInbound(); Input.join(); } diff --git a/nixd/include/nixd/Support/AutoHUPPID.h b/nixd/include/nixd/Support/AutoHUPPID.h deleted file mode 100644 index 0c1a20126..000000000 --- a/nixd/include/nixd/Support/AutoHUPPID.h +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include // NOLINT(modernize-deprecated-headers) - -namespace nixd::util { - -class AutoHUPPID { - pid_t Pid; - -public: - AutoHUPPID(pid_t Pid) noexcept : Pid(Pid) {} - - ~AutoHUPPID() { kill(Pid, SIGKILL); } - - operator pid_t() const { return Pid; } -}; - -} // namespace nixd::util diff --git a/nixd/include/nixd/Support/PipedProc.h b/nixd/include/nixd/Support/PipedProc.h index ab61bde52..123be7984 100644 --- a/nixd/include/nixd/Support/PipedProc.h +++ b/nixd/include/nixd/Support/PipedProc.h @@ -1,12 +1,13 @@ #pragma once #include "AutoCloseFD.h" -#include "AutoHUPPID.h" + +#include namespace nixd::util { struct PipedProc { - AutoHUPPID PID; + pid_t PID; // Piped descriptors AutoCloseFD Stdin; diff --git a/nixd/lib/Eval/AttrSetClient.cpp b/nixd/lib/Eval/AttrSetClient.cpp index 3c36293fa..cf35e6162 100644 --- a/nixd/lib/Eval/AttrSetClient.cpp +++ b/nixd/lib/Eval/AttrSetClient.cpp @@ -2,6 +2,8 @@ #include "nixd/Eval/AttrSetClient.h" +#include // NOLINT(modernize-deprecated-headers) + using namespace nixd; using namespace lspserver; @@ -18,6 +20,7 @@ AttrSetClient::AttrSetClient(std::unique_ptr In, mkOutMethod("attrset/optionInfo"); OptionComplete = mkOutMethod( "attrset/optionComplete"); + Exit = mkOutNotifiction("exit"); } const char *AttrSetClient::getExe() {