]> git.saurik.com Git - wxWidgets.git/commitdiff
Return exit code as signed integer from wxExecute(wxEXEC_SYNC).
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 18 Mar 2010 15:51:19 +0000 (15:51 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 18 Mar 2010 15:51:19 +0000 (15:51 +0000)
The caller expects the function to return -1 if the child process exited with
-1 error code and not 255 that was returned before. The function is also
documented as returning -1 if the execution fails which wasn't true neither.

Fix this by explicitly handling the exit code as signed.

Closes #11824.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63710 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
src/unix/utilsunx.cpp

index 6c0fca69bc489eb4d3b384eae32c8f7a852a5c93..57b498e5bc91aaa5f277dac7e596009f5f20f54c 100644 (file)
@@ -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().
 
index 2e9973b6da81370f3a26771f0e860aab904f1b64..219c7727cbb8da1d2c9ce6581c7611dd63927411 100644 (file)
@@ -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;