From 4bf8dbe3ea4063af9e7141ca0bd959fcfb147223 Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Wed, 20 Dec 2017 09:09:05 -0800 Subject: [PATCH] Move std::cin.tie to main --- src/command_line.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/command_line.cc b/src/command_line.cc index 8c8d03cc..f262a88c 100644 --- a/src/command_line.cc +++ b/src/command_line.cc @@ -830,6 +830,10 @@ void RunQueryDbThread(const std::string& bin_name, // |ipc| is connected to a server. void LaunchStdinLoop(Config* config, std::unordered_map* request_times) { + // If flushing cin requires flushing cout there could be deadlocks in some + // clients. + std::cin.tie(nullptr); + WorkThread::StartThread("stdin", [request_times]() { IpcManager* ipc = IpcManager::instance(); @@ -956,7 +960,6 @@ void LanguageServerMain(const std::string& bin_name, QueueManager queue(waiter); std::unordered_map request_times; - std::cin.tie(NULL); LaunchStdinLoop(config, &request_times); // We run a dedicated thread for writing to stdout because there can be an