int
-windows32_openpipe (int *pipedes, pid_t *pid_p, char **command_argv, char **envp)
+windows32_openpipe (int *pipedes, int errfd, pid_t *pid_p, char **command_argv, char **envp)
{
SECURITY_ATTRIBUTES saAttr;
HANDLE hIn = INVALID_HANDLE_VALUE;
return -1;
}
}
- tmpErr = GetStdHandle (STD_ERROR_HANDLE);
+ tmpErr = (HANDLE)_get_osfhandle (errfd);
if (DuplicateHandle (GetCurrentProcess (), tmpErr,
GetCurrentProcess (), &hErr,
0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE)
return o;
}
#elif defined(WINDOWS32)
- windows32_openpipe (pipedes, &pid, command_argv, envp);
+ windows32_openpipe (pipedes, errfd, &pid, command_argv, envp);
/* Restore the value of just_print_flag. */
just_print_flag = j_p_f;
sync_Path_environment ();
#ifndef NO_OUTPUT_SYNC
- /* Divert child output if output_sync in use. Don't capture
- recursive make output unless we are synchronizing "make" mode. */
- if (child->output.syncout)
- hPID = process_easy (argv, child->environment,
- child->output.out, child->output.err);
- else
+ /* Divert child output if output_sync in use. */
+ if (child->output.syncout)
+ {
+ if (child->output.out >= 0)
+ outfd = child->output.out;
+ if (child->output.err >= 0)
+ errfd = child->output.err;
+ }
+#else
+ outfd = errfd = -1;
#endif
- hPID = process_easy (argv, child->environment, -1, -1);
+ hPID = process_easy (argv, child->environment, outfd, errfd);
if (hPID != INVALID_HANDLE_VALUE)
child->pid = (pid_t) hPID;