+ if ( rc == 0 )
+ {
+ // This can only happen if the child application closes our dummy pipe
+ // that is used to monitor its lifetime; in that case, our best bet is
+ // to pretend the process did terminate, because otherwise wxExecute()
+ // would hang indefinitely (OnReadWaiting() won't be called again, the
+ // descriptor is closed now).
+ wxLogDebug("Child process (PID %d) still alive but pipe closed so "
+ "generating a close notification", pid);
+ }
+ else if ( rc == -1 )
+ {
+ wxLogLastError(wxString::Format("waitpid(%d)", pid));
+ }
+ else // child did terminate
+ {
+ wxASSERT_MSG( rc == pid, "unexpected waitpid() return value" );
+
+ if ( WIFEXITED(status) )
+ return WEXITSTATUS(status);
+ else if ( WIFSIGNALED(status) )
+ return -WTERMSIG(status);
+ else
+ {
+ wxLogError("Child process (PID %d) exited for unknown reason, "
+ "status = %d", pid, status);