fixed the exit code detection for async processes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11787 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2001-10-02 19:22:24 +00:00
parent 334f0d2c11
commit 447f908aff
3 changed files with 19 additions and 27 deletions

View File

@@ -148,12 +148,19 @@ static void GTK_EndProcessDetector(gpointer data, gint source,
// generate G_IO_HUP notification even when it simply tries to read from a
// closed fd and hasn't terminated at all
int pid = (proc_data->pid > 0) ? proc_data->pid : -(proc_data->pid);
if ( waitpid(pid, NULL, WNOHANG) == 0 )
int status = 0;
int rc = waitpid(pid, &status, WNOHANG);
if ( rc == 0 )
{
// no, it didn't exit yet, continue waiting
return;
}
// set exit code to -1 if something bad happened
proc_data->exitcode = rc != -1 && WIFEXITED(status) ? WEXITSTATUS(status)
: -1;
// child exited, end waiting
close(source);