Skip to content

Commit 6d23bf6

Browse files
committed
[SourceKit] Abort the SourceKitService proces on a SIGTERM
Sending a `SIGTERM` to sourcekitd XPC service lead to very surprising results: XPC thought that the process was about to die and sends a Connection Interrupted notification to the client. But other than that, we didn’t actually handle the signal and the service stayed alive. This caused us to send a `sema_disabled` notification to the client but since the service never got relaunched, we never sent the corresponding `sema_enabled` notification. To fix this, just properly die on `SIGTERM` by calling `abort`.
1 parent 11ef6e5 commit 6d23bf6

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tools/SourceKit/tools/sourcekitd/bin/XPC/Service/XPCService.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "llvm/Support/Path.h"
2727
#include "llvm/Support/Threading.h"
2828

29+
#include <csignal>
2930
#include <xpc/xpc.h>
3031

3132
using namespace SourceKit;
@@ -385,6 +386,7 @@ static void fatal_error_handler(void *user_data, const char *reason,
385386
}
386387

387388
int main(int argc, const char *argv[]) {
389+
std::signal(SIGTERM, SIG_DFL);
388390
llvm::install_fatal_error_handler(fatal_error_handler, 0);
389391
sourcekitd::enableLogging("sourcekit-serv");
390392
sourcekitd_set_uid_handlers(

0 commit comments

Comments
 (0)