Browse Source

Now ignores SIGPIPE, and added process->write check in source_language_protocol.cc

merge-requests/365/head
eidheim 8 years ago
parent
commit
be85fc65c1
  1. 6
      src/juci.cc
  2. 11
      src/source_language_protocol.cc

6
src/juci.cc

@ -5,6 +5,9 @@
#include "menu.h"
#include "config.h"
#include "terminal.h"
#ifndef _WIN32
#include <signal.h>
#endif
int Application::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine> &cmd) {
Glib::set_prgname("juci");
@ -124,5 +127,8 @@ Application::Application() : Gtk::Application("no.sout.juci", Gio::APPLICATION_N
}
int main(int argc, char *argv[]) {
#ifndef _WIN32
signal(SIGPIPE, SIG_IGN); // Do not terminate application when writing to a process fails
#endif
return Application().run(argc, argv);
}

11
src/source_language_protocol.cc

@ -232,7 +232,16 @@ void LanguageProtocol::Client::write_request(const std::string &method, const st
auto message="Content-Length: "+std::to_string(content.size())+"\r\n\r\n"+content;
if(output_messages_and_errors)
std::cout << "Language client: " << content << std::endl;
process->write(message);
if(!process->write(message)) {
auto id_it=handlers.find(message_id);
if(id_it!=handlers.end()) {
auto function=std::move(id_it->second);
lock.unlock();
function(boost::property_tree::ptree(), false);
lock.lock();
handlers.erase(id_it->first);
}
}
}
void LanguageProtocol::Client::write_notification(const std::string &method, const std::string &params) {

Loading…
Cancel
Save