diff --git a/api/QgisUntwine.cpp b/api/QgisUntwine.cpp index f79e993..87a9b34 100644 --- a/api/QgisUntwine.cpp +++ b/api/QgisUntwine.cpp @@ -57,6 +57,9 @@ std::string QgisUntwine::errorMessage() const { readPipe(); + if ( m_errorMsg.empty() && m_exitCode != 0 ) + m_errorMsg = "Untwine exited with code: " + std::to_string( m_exitCode ); + return m_errorMsg; } diff --git a/api/QgisUntwine.hpp b/api/QgisUntwine.hpp index b7e5a87..fc90955 100644 --- a/api/QgisUntwine.hpp +++ b/api/QgisUntwine.hpp @@ -39,9 +39,11 @@ class QgisUntwine #ifndef _WIN32 pid_t m_pid; int m_progressFd; + int m_exitCode; #else HANDLE m_pid; HANDLE m_progressFd; + DWORD m_exitCode; #endif bool start(Options& options); diff --git a/api/QgisUntwine_unix.cpp b/api/QgisUntwine_unix.cpp index 673e06f..7808f46 100644 --- a/api/QgisUntwine_unix.cpp +++ b/api/QgisUntwine_unix.cpp @@ -65,7 +65,7 @@ bool QgisUntwine::stop() if (!m_running) return false; ::kill(m_pid, SIGINT); - (void)waitpid(m_pid, nullptr, 0); + (void)waitpid(m_pid, &m_exitCode, 0); m_pid = 0; return true; } @@ -78,7 +78,7 @@ void QgisUntwine::childStopped() bool QgisUntwine::running() { - if (m_running && (::waitpid(m_pid, nullptr, WNOHANG) != 0)) + if (m_running && (::waitpid(m_pid, &m_exitCode, WNOHANG) != 0)) childStopped(); return m_running; } diff --git a/api/QgisUntwine_win.cpp b/api/QgisUntwine_win.cpp index 7469655..d837a35 100644 --- a/api/QgisUntwine_win.cpp +++ b/api/QgisUntwine_win.cpp @@ -76,6 +76,7 @@ bool QgisUntwine::stop() void QgisUntwine::childStopped() { m_running = false; + GetExitCodeProcess(m_pid, &m_exitCode); CloseHandle(m_progressFd); CloseHandle(m_pid); }