diff --git a/docs/changes.txt b/docs/changes.txt index 6c0fca69bc..57b498e5bc 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -441,6 +441,7 @@ All: Unix: +- Return signed return code from wxExecute(wxEXEC_SYNC). - Allow to use WX_APPNAME_DATA_DIR environment var to override the return value of wxStandardPaths::GetDataDir(). diff --git a/src/unix/utilsunx.cpp b/src/unix/utilsunx.cpp index 2e9973b6da..219c7727cb 100644 --- a/src/unix/utilsunx.cpp +++ b/src/unix/utilsunx.cpp @@ -1373,15 +1373,21 @@ int DoWaitForChild(int pid, int flags = 0) { wxASSERT_MSG( rc == pid, "unexpected waitpid() return value" ); + // notice that the caller expects the exit code to be signed, e.g. -1 + // instead of 255 so don't assign WEXITSTATUS() to an int + signed char exitcode; if ( WIFEXITED(status) ) - return WEXITSTATUS(status); + exitcode = WEXITSTATUS(status); else if ( WIFSIGNALED(status) ) - return -WTERMSIG(status); + exitcode = -WTERMSIG(status); else { wxLogError("Child process (PID %d) exited for unknown reason, " "status = %d", pid, status); + exitcode = -1; } + + return exitcode; } return -1;