X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dbd25330c5a762ed22b1ca5deb8acd56da419fdf..180db9083613b9b6eca8451ee19553c6581f5505:/src/gtk/utilsgtk.cpp?ds=sidebyside diff --git a/src/gtk/utilsgtk.cpp b/src/gtk/utilsgtk.cpp index f1346abc17..1296a0f762 100644 --- a/src/gtk/utilsgtk.cpp +++ b/src/gtk/utilsgtk.cpp @@ -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);