From c3d7151ba5abf278481b0d851a8686f25f28e394 Mon Sep 17 00:00:00 2001 From: eranif Date: Mar 11 2019 07:29:46 +0000 Subject: reverted unix process management commit which caused a regression (unable to debug) --- diff --git a/CodeLite/unixprocess_impl.cpp b/CodeLite/unixprocess_impl.cpp index 91e25a1..e34212a 100644 --- a/CodeLite/unixprocess_impl.cpp +++ b/CodeLite/unixprocess_impl.cpp @@ -28,8 +28,6 @@ #include #include "file_logger.h" #include "fileutils.h" -#include -#include "SocketAPI/clSocketBase.h" #if defined(__WXMAC__) || defined(__WXGTK__) @@ -390,41 +388,21 @@ bool UnixProcessImpl::Read(wxString& buff, wxString& buffErr) bool UnixProcessImpl::Write(const wxString& buff) { - // Sanity - std::string cstr = FileUtils::ToStdString(buff); - return Write(cstr); - // if(!IsRedirect()) { return false; } - // m_writerThread->Write(buff + "\n"); - // return true; + wxString tmpbuf = buff; + tmpbuf << "\n"; + std::string cstr = FileUtils::ToStdString(tmpbuf); + + int bytes = write(GetWriteHandle(), cstr.c_str(), cstr.length()); + return bytes == (int)cstr.length(); } bool UnixProcessImpl::Write(const std::string& buff) { - // Sanity - if(!IsRedirect()) { return false; } - std::string tmp = buff; - tmp += "\n"; - - clSocketBase c(GetWriteHandle()); - c.MakeSocketBlocking(false); + std::string tmpbuf = buff; + tmpbuf.append("\n"); - while(!tmp.empty()) { - errno = 0; - int bytes = ::write(GetWriteHandle(), tmp.c_str(), (tmp.length() > 1024 ? 1024 : tmp.length())); - int errCode = errno; - if(bytes < 0) { - if(((errCode == EWOULDBLOCK) || (errCode == EAGAIN))) { - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - } else { - clWARNING() << "Write error:" << strerror(errCode); - return false; - } - } else { - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - tmp.erase(0, bytes); - } - } - return true; + int bytes = write(GetWriteHandle(), tmpbuf.c_str(), tmpbuf.length()); + return bytes == (int)tmpbuf.length(); } IProcess* UnixProcessImpl::Execute(wxEvtHandler* parent, const wxString& cmd, size_t flags,