Better shutdown

This commit is contained in:
Fangrui Song 2018-01-14 22:53:51 -08:00
parent 13728a0fae
commit 96a23bc573
4 changed files with 7 additions and 20 deletions

View File

@ -334,20 +334,12 @@ void LaunchStdoutThread(std::unordered_map<IpcId, Timer>* request_times,
} }
if (g_log_stdin_stdout_to_stderr) { if (g_log_stdin_stdout_to_stderr) {
try { std::cerr << "[COUT] |" << message.content << "|\n";
std::cerr << "[COUT] |" << message.content << "|\n"; std::cerr.flush();
std::cerr.flush();
} catch (std::ios_base::failure&) {
// TODO Ignore for now
}
} }
try { std::cout << message.content;
std::cout << message.content; std::cout.flush();
std::cout.flush();
} catch (std::ios_base::failure&) {
// TODO Ignore for now
}
} }
} }
}); });

View File

@ -107,13 +107,6 @@ TEST_SUITE("FindIncludeLine") {
} }
optional<char> ReadCharFromStdinBlocking() { optional<char> ReadCharFromStdinBlocking() {
// Bad stdin means parent process has probably exited. Either way, cquery
// can no longer be communicated with so just exit.
if (!std::cin.good()) {
LOG_S(FATAL) << "std::cin.good() is false; exiting";
exit(1);
}
char c = 0; char c = 0;
std::cin.read(&c, 1); std::cin.read(&c, 1);
return c; return c;

View File

@ -6,7 +6,7 @@ struct Ipc_Shutdown : public IpcMessage<Ipc_Shutdown> {
static const IpcId kIpcId = IpcId::Shutdown; static const IpcId kIpcId = IpcId::Shutdown;
lsRequestId id; lsRequestId id;
}; };
MAKE_REFLECT_EMPTY_STRUCT(Ipc_Shutdown, id); MAKE_REFLECT_STRUCT(Ipc_Shutdown, id);
REGISTER_IPC_MESSAGE(Ipc_Shutdown); REGISTER_IPC_MESSAGE(Ipc_Shutdown);
struct Out_Shutdown : public lsOutMessage<Out_Shutdown> { struct Out_Shutdown : public lsOutMessage<Out_Shutdown> {

View File

@ -349,6 +349,8 @@ optional<lsRange> GetLsRange(WorkingFile* working_file, const Range& location) {
// class/struct definitions. // class/struct definitions.
if (*end < *start) if (*end < *start)
*end = *start + (location.end.line - location.start.line); *end = *start + (location.end.line - location.start.line);
if (*start == *end && start_column > end_column)
end_column = start_column;
return lsRange(lsPosition(*start, start_column), return lsRange(lsPosition(*start, start_column),
lsPosition(*end, end_column)); lsPosition(*end, end_column));