We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 2840c7d + c508dfd commit 21df377Copy full SHA for 21df377
Sources/sourcekit-lsp/main.swift
@@ -107,10 +107,20 @@ do {
107
exit(1)
108
}
109
110
+// Dup stdout and redirect the fd to stderr so that a careless print()
111
+// will not break our connection stream.
112
+let realStdout = dup(STDOUT_FILENO)
113
+if realStdout == -1 {
114
+ fatalError("failed to dup stdout: \(strerror(errno))")
115
+}
116
+if dup2(STDERR_FILENO, STDOUT_FILENO) == -1 {
117
+ fatalError("failed to redirect stdout -> stderr: \(strerror(errno))")
118
119
+
120
let clientConnection = JSONRPCConnection(
121
protocol: MessageRegistry.lspProtocol,
122
inFD: STDIN_FILENO,
- outFD: STDOUT_FILENO,
123
+ outFD: realStdout,
124
syncRequests: options.syncRequests)
125
126
let installPath = AbsolutePath(Bundle.main.bundlePath)
0 commit comments