mirror of
https://github.com/apple/sourcekit-lsp.git
synced 2026-03-02 18:23:24 +01:00
Workaround SR-13822 by keeping the file handle alive for the connection
On Linux, the file handle is closing the file descriptor on deinit despite `closeOnDealloc: false` (https://bugs.swift.org/browse/SR-13822). Workaround by keping the FileHandle alive. rdar://70995458
This commit is contained in:
@@ -159,10 +159,12 @@ struct Main: ParsableCommand {
|
||||
fatalError("failed to redirect stdout -> stderr: \(strerror(errno)!)")
|
||||
}
|
||||
|
||||
let realStdoutHandle = FileHandle(fileDescriptor: realStdout, closeOnDealloc: false)
|
||||
|
||||
let clientConnection = JSONRPCConnection(
|
||||
protocol: MessageRegistry.lspProtocol,
|
||||
inFD: FileHandle.standardInput,
|
||||
outFD: FileHandle(fileDescriptor: realStdout, closeOnDealloc: false),
|
||||
outFD: realStdoutHandle,
|
||||
syncRequests: syncRequests
|
||||
)
|
||||
|
||||
@@ -174,6 +176,9 @@ struct Main: ParsableCommand {
|
||||
})
|
||||
clientConnection.start(receiveHandler: server, closeHandler: {
|
||||
server.prepareForExit()
|
||||
// FIXME: keep the FileHandle alive until we close the connection to
|
||||
// workaround SR-13822.
|
||||
withExtendedLifetime(realStdoutHandle) {}
|
||||
// Use _Exit to avoid running static destructors due to SR-12668.
|
||||
_Exit(0)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user