+
+ if (env)
+ status = (((flags & PEX_SEARCH) != 0 ? spawnvpe : spawnve)
+ (P_WAIT, executable, argv, env));
+ else
+ status = (((flags & PEX_SEARCH) != 0 ? spawnvp : spawnv)
+ (P_WAIT, executable, argv));
+
+ if (status == -1)
+ {
+ *err = errno;
+ *errmsg = ((flags & PEX_SEARCH) != 0) ? "spawnvp" : "spawnv";
+ }
+
+ if (in != STDIN_FILE_NO)
+ {
+ if (dup2 (org_in, STDIN_FILE_NO) < 0)
+ {
+ *err = errno;
+ *errmsg = "dup2";
+ return -1;
+ }
+ if (close (org_in) < 0)
+ {
+ *err = errno;
+ *errmsg = "close";
+ return -1;
+ }
+ }
+
+ if (out != STDOUT_FILE_NO)
+ {
+ if (dup2 (org_out, STDOUT_FILE_NO) < 0)
+ {
+ *err = errno;
+ *errmsg = "dup2";
+ return -1;
+ }
+ if (close (org_out) < 0)
+ {
+ *err = errno;
+ *errmsg = "close";
+ return -1;
+ }
+ }
+
+ if (errdes != STDERR_FILE_NO
+ || (flags & PEX_STDERR_TO_STDOUT) != 0)
+ {
+ if (dup2 (org_errdes, STDERR_FILE_NO) < 0)
+ {
+ *err = errno;
+ *errmsg = "dup2";
+ return -1;
+ }
+ if (close (org_errdes) < 0)
+ {
+ *err = errno;
+ *errmsg = "close";
+ return -1;
+ }
+ }
+
+ /* Save the exit status for later. When we are called, obj->count
+ is the number of children which have executed before this
+ one. */
+ statuses = (int *) obj->sysdep;
+ statuses = XRESIZEVEC (int, statuses, obj->count + 1);
+ statuses[obj->count] = status;
+ obj->sysdep = (void *) statuses;
+
+ return obj->count;
+}
+
+/* Wait for a child process to complete. Actually the child process
+ has already completed, and we just need to return the exit
+ status. */
+
+static int
+pex_djgpp_wait (struct pex_obj *obj, long pid, int *status,
+ struct pex_time *time, int done ATTRIBUTE_UNUSED,
+ const char **errmsg ATTRIBUTE_UNUSED,
+ int *err ATTRIBUTE_UNUSED)
+{
+ int *statuses;
+
+ if (time != NULL)
+ memset (time, 0, sizeof *time);
+
+ statuses = (int *) obj->sysdep;
+ *status = statuses[pid];
+
+ return 0;