Skip to content

Commit

Permalink
Return the exit code to QgisUntwine in case of no error message and n…
Browse files Browse the repository at this point in the history
…o clean exit (#159)
  • Loading branch information
uclaros authored Feb 22, 2024
1 parent 7401b13 commit c19046b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions api/QgisUntwine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions api/QgisUntwine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions api/QgisUntwine_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions api/QgisUntwine_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ bool QgisUntwine::stop()
void QgisUntwine::childStopped()
{
m_running = false;
GetExitCodeProcess(m_pid, &m_exitCode);
CloseHandle(m_progressFd);
CloseHandle(m_pid);
}
Expand Down

0 comments on commit c19046b

Please sign in to comment.