diff --git a/src/viewer/svutil.cpp b/src/viewer/svutil.cpp index c86594cded..ca03ed8d81 100644 --- a/src/viewer/svutil.cpp +++ b/src/viewer/svutil.cpp @@ -26,6 +26,7 @@ #include "svutil.h" +#include #include #include #include @@ -109,6 +110,9 @@ void SVSync::StartProcess(const char *executable, const char *args) { } argv[argc] = nullptr; execvp(executable, argv.get()); + // execvp returns only if execution failed. + perror(executable); + _exit(EXIT_FAILURE); } # endif } @@ -168,8 +172,23 @@ void SVNetwork::Send(const char *msg) { void SVNetwork::Flush() { std::lock_guard guard(mutex_send_); while (!msg_buffer_out_.empty()) { - int i = send(stream_, msg_buffer_out_.c_str(), msg_buffer_out_.length(), 0); - msg_buffer_out_.erase(0, i); + auto i = + send(stream_, msg_buffer_out_.c_str(), msg_buffer_out_.length(), 0); + + if (i < 0) { +# ifndef _WIN32 + if (errno == EINTR) { + continue; + } +# endif + break; + } + + if (i == 0) { + break; + } + + msg_buffer_out_.erase(0, static_cast(i)); } }