* child_info.h (child_info_spawn::__stdin): New element.
(child_info_spawn::__stdin): Ditto. (CURR_CHILD_INFO_MAGIC): Regenerate. * dcrt0.cc (check_sanity_and_sync): Minor cleanup. (child_info_spawn::handle_spawn): Handle new __std* elements by calling move_fd. * dtable.cc (dtable::move_fd): Define new function. * dtable.h (dtable::move_fd): Declare new function. * fhandler.h (fhandler_pipe::popen_pid): Declare new element. * fhandler.h (fhandler_pipe::get_popen_pid): Define new function. * fhandler.h (fhandler_pipe::set_popen_pid): Ditto. * pipe.cc (fhandler_pipe::fhandler_pipe): Zero popen_pid. (fhandler_pipe::dup): Ditto. * spawn.cc (handle): Change second argument to bool. (spawn_guts): Accept __stdin/__stdout arguments and set them appropriately in child_info structure and in STARTUPINFO structure. * syscalls.cc (popen): New cygwin-specific implementation using spawn. (pclose): Ditto. * winsup.h (spawn_guts): Accommodate new arguments for spawn_guts. * fhandler.cc (fhandler_base::set_no_inheritance): Make second arg a bool. * fhandler.h (fhandler_base::set_no_inheritance): Ditto for declaration. * child_info.h (child_info::msv_count): Rename from the now-inappropriate "zero". (child_info_spawn::filler): Add filler to work around Vista bug. (child_info_fork::filler): Ditto. * dcrt0.cc (get_cygwin_startup_info): Remove "zero" check since it is now always filled out. * fork.cc (frok::parent): Move ch.zero manipulation to constructor. * spawn.cc (spawn_guts): Ditto. Remove _ch wrapper. * sigproc.cc (child_info::child_info): Initialize starter[]. * shared.cc (shared_info::heap_slop_size): Remove noisy system_printfs. * shared_info.h (CURR_SHARED_MAGIC): Regenerate.
This commit is contained in:
@ -210,7 +210,7 @@ find_exec (const char *name, path_conv& buf, const char *mywinenv,
|
||||
/* Utility for spawn_guts. */
|
||||
|
||||
static HANDLE
|
||||
handle (int fd, int direction)
|
||||
handle (int fd, bool writing)
|
||||
{
|
||||
HANDLE h;
|
||||
cygheap_fdget cfd (fd);
|
||||
@ -219,10 +219,11 @@ handle (int fd, int direction)
|
||||
h = INVALID_HANDLE_VALUE;
|
||||
else if (cfd->close_on_exec ())
|
||||
h = INVALID_HANDLE_VALUE;
|
||||
else if (direction == 0)
|
||||
else if (!writing)
|
||||
h = cfd->get_handle ();
|
||||
else
|
||||
h = cfd->get_output_handle ();
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
@ -259,9 +260,9 @@ do_cleanup (void *args)
|
||||
}
|
||||
|
||||
|
||||
static int __stdcall
|
||||
int __stdcall
|
||||
spawn_guts (const char * prog_arg, const char *const *argv,
|
||||
const char *const envp[], int mode)
|
||||
const char *const envp[], int mode, int __stdin, int __stdout)
|
||||
{
|
||||
bool rc;
|
||||
pid_t cygpid;
|
||||
@ -298,14 +299,7 @@ spawn_guts (const char * prog_arg, const char *const *argv,
|
||||
pthread_cleanup_push (do_cleanup, (void *) &cleanup);
|
||||
av newargv;
|
||||
linebuf one_line;
|
||||
/* Allocate slightly bigger for call to CreateProcess to accomodate
|
||||
needs_count_in_si_lpres2. */
|
||||
struct {
|
||||
child_info_spawn ch;
|
||||
char filler[4];
|
||||
} _ch;
|
||||
#define ch _ch.ch
|
||||
|
||||
child_info_spawn ch;
|
||||
char *envblock = NULL;
|
||||
path_conv real_path;
|
||||
bool reset_sendsig = false;
|
||||
@ -316,7 +310,8 @@ spawn_guts (const char * prog_arg, const char *const *argv,
|
||||
cygheap_exec_info *moreinfo;
|
||||
|
||||
bool null_app_name = false;
|
||||
STARTUPINFO si = {0, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL};
|
||||
STARTUPINFO si = {0, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL,
|
||||
NULL, NULL, NULL};
|
||||
int looped = 0;
|
||||
HANDLE orig_wr_proc_pipe = NULL;
|
||||
|
||||
@ -411,10 +406,13 @@ spawn_guts (const char * prog_arg, const char *const *argv,
|
||||
pi.dwProcessId = pi.dwThreadId = 0;
|
||||
si.lpReserved = NULL;
|
||||
si.lpDesktop = NULL;
|
||||
|
||||
/* Set up needed handles for stdio */
|
||||
si.dwFlags = STARTF_USESTDHANDLES;
|
||||
si.hStdInput = handle (0, 0); /* Get input handle */
|
||||
si.hStdOutput = handle (1, 1); /* Get output handle */
|
||||
si.hStdError = handle (2, 1); /* Get output handle */
|
||||
si.hStdInput = handle ((__stdin < 0 ? 0 : __stdin), false);
|
||||
si.hStdOutput = handle ((__stdout < 0 ? 1 : __stdout), true);
|
||||
si.hStdError = handle (2, true);
|
||||
|
||||
si.cb = sizeof (si);
|
||||
if (!wincap.pty_needs_alloc_console () && newargv.iscui && myself->ctty == -1)
|
||||
{
|
||||
@ -483,14 +481,12 @@ spawn_guts (const char * prog_arg, const char *const *argv,
|
||||
}
|
||||
ch.set (chtype, real_path.iscygexec ());
|
||||
ch.moreinfo = moreinfo;
|
||||
ch.__stdin = __stdin;
|
||||
ch.__stdout = __stdout;
|
||||
|
||||
si.lpReserved2 = (LPBYTE) &ch;
|
||||
si.cbReserved2 = sizeof (ch);
|
||||
|
||||
/* See comment in dcrt0.cc, function get_cygwin_startup_info. */
|
||||
if (wincap.needs_count_in_si_lpres2 ())
|
||||
ch.zero[0] = sizeof (ch) / 5;
|
||||
|
||||
/* When ruid != euid we create the new process under the current original
|
||||
account and impersonate in child, this way maintaining the different
|
||||
effective vs. real ids.
|
||||
|
Reference in New Issue
Block a user