Skip to content

Commit

Permalink
nixd: don't send SIGKILL to child processes, exit() them cleanly
Browse files Browse the repository at this point in the history
  • Loading branch information
inclyc committed Apr 17, 2024
1 parent 5e80c76 commit a8154f8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 19 deletions.
5 changes: 5 additions & 0 deletions nixd/include/nixd/Eval/AttrSetClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class AttrSetClient : public lspserver::LSPServer {
lspserver::Callback<OptionCompleteResponse> Reply)>
OptionComplete;

llvm::unique_function<void(std::nullptr_t)> Exit;

public:
AttrSetClient(std::unique_ptr<lspserver::InboundPort> In,
std::unique_ptr<lspserver::OutboundPort> Out);
Expand Down Expand Up @@ -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();
Expand All @@ -78,6 +82,7 @@ class AttrSetClientProc {
/// \returns nullptr if it has been dead.
AttrSetClient *client();
~AttrSetClientProc() {
Client.exit();
Client.closeInbound();
Input.join();
}
Expand Down
17 changes: 0 additions & 17 deletions nixd/include/nixd/Support/AutoHUPPID.h

This file was deleted.

5 changes: 3 additions & 2 deletions nixd/include/nixd/Support/PipedProc.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#pragma once

#include "AutoCloseFD.h"
#include "AutoHUPPID.h"

#include <sys/types.h>

namespace nixd::util {

struct PipedProc {
AutoHUPPID PID;
pid_t PID;

// Piped descriptors
AutoCloseFD Stdin;
Expand Down
3 changes: 3 additions & 0 deletions nixd/lib/Eval/AttrSetClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "nixd/Eval/AttrSetClient.h"

#include <signal.h> // NOLINT(modernize-deprecated-headers)

using namespace nixd;
using namespace lspserver;

Expand All @@ -18,6 +20,7 @@ AttrSetClient::AttrSetClient(std::unique_ptr<lspserver::InboundPort> In,
mkOutMethod<AttrPathInfoParams, OptionInfoResponse>("attrset/optionInfo");
OptionComplete = mkOutMethod<AttrPathCompleteParams, OptionCompleteResponse>(
"attrset/optionComplete");
Exit = mkOutNotifiction<std::nullptr_t>("exit");
}

const char *AttrSetClient::getExe() {
Expand Down

0 comments on commit a8154f8

Please sign in to comment.