- // we're in parent
- close(end_proc_detect[1]); // close writing side
- data->tag = gdk_input_add(end_proc_detect[0], GDK_INPUT_READ,
- GTK_EndProcessDetector, (gpointer)data);
- data->pid = pid;
- if (!sync)
- {
- data->process = process;
- }
- else
- {
- data->process = (wxProcess *) NULL;
- data->pid = -(data->pid);
-
- while (data->pid != 0)
- wxYield();
-
- delete data;
- }
-
- // @@@ our return value indicates success even if execvp() in the child
- // failed!
- return pid;
+ // we're in parent
+ close(end_proc_detect[1]); // close writing side
+ data->tag = gdk_input_add(end_proc_detect[0], GDK_INPUT_READ,
+ GTK_EndProcessDetector, (gpointer)data);
+ if ( sync )
+ {
+ wxASSERT_MSG( !process, "wxProcess param ignored for sync exec" );
+ data->process = NULL;
+
+ // sync execution: indicate it by negating the pid
+ data->pid = -pid;
+
+ // it will be set to 0 from GTK_EndProcessDetector
+ while (data->pid != 0)
+ wxYield();
+
+ int exitcode = data->exitcode;
+
+ delete data;
+
+ return exitcode;
+ }
+ else
+ {
+ // async execution, nothing special to do - caller will be
+ // notified about the process terminationif process != NULL, data
+ // will be deleted in GTK_EndProcessDetector
+ data->process = process;
+ data->pid = pid;
+
+ return pid;
+ }