summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/spawn.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2005-12-19 04:34:13 +0000
committerChristopher Faylor <me@cgf.cx>2005-12-19 04:34:13 +0000
commit65438ec635d9cede44bb9e59438f80668422d704 (patch)
tree7f7d9c84558ab4b6ae8868b05cf49e51c8f69b4f /winsup/cygwin/spawn.cc
parentca9271d1b6c70a60640e32a2cdb729d51e2037e7 (diff)
downloadcygnal-65438ec635d9cede44bb9e59438f80668422d704.tar.gz
cygnal-65438ec635d9cede44bb9e59438f80668422d704.tar.bz2
cygnal-65438ec635d9cede44bb9e59438f80668422d704.zip
* fhandler.h (fhandler_pipe::fixup_in_child): Declare new function.
(fhandler_console::invisible_console): Declare new variable. (fhandler_console::need_invisible): Ditto. (fhandler_console::has_a): Ditto. * fhandler_console.cc (set_console_state_for_spawn): Eliminate return value. Set up an invisible console if necessary prior to spawning. (fhandler_console::invisible_console): Define. * fhandler_tty.cc (fhandler_tty_slave::open): Use fhandler_console::invisible_console to setup an invisible console. * pipe.cc (fhandler_pipe::fixup_in_child): Define new function from fixup_after_exec. (fhandler_pipe::fixup_after_exec): Use fixup_in_child when appropriate. (fhandler_pipe::fixup_after_fork): Ditto. * spawn.cc (handle): Reorganize and modernize a little. (spawn_guts): Rely on set_console_state_for_spawn to set the console into the right state but don't create the process with "detached" flag if we have no controlling tty since that confuses 'cmd'. * dtable.cc (dtable::stdio_init): Don't set console as controlling terminal if we have an invisible console. * sigproc.cc (child_info::sync): Use correct name in ForceCloseHandle1.
Diffstat (limited to 'winsup/cygwin/spawn.cc')
-rw-r--r--winsup/cygwin/spawn.cc27
1 files changed, 16 insertions, 11 deletions
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 463ec48fa..df5cde10e 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -200,17 +200,20 @@ find_exec (const char *name, path_conv& buf, const char *mywinenv,
/* Utility for spawn_guts. */
static HANDLE
-handle (int n, int direction)
+handle (int fd, int direction)
{
- fhandler_base *fh = cygheap->fdtab[n];
-
- if (!fh)
- return INVALID_HANDLE_VALUE;
- if (fh->close_on_exec ())
- return INVALID_HANDLE_VALUE;
- if (direction == 0)
- return fh->get_handle ();
- return fh->get_output_handle ();
+ HANDLE h;
+ cygheap_fdget cfd (fd);
+
+ if (cfd < 0)
+ h = INVALID_HANDLE_VALUE;
+ else if (cfd->close_on_exec ())
+ h = INVALID_HANDLE_VALUE;
+ else if (direction == 0)
+ h = cfd->get_handle ();
+ else
+ h = cfd->get_output_handle ();
+ return h;
}
int
@@ -580,7 +583,9 @@ spawn_guts (const char * prog_arg, const char *const *argv,
sigproc_printf ("priority class %d", flags);
flags |= CREATE_DEFAULT_ERROR_MODE | CREATE_SEPARATE_WOW_VDM;
- if (mode == _P_DETACH || !set_console_state_for_spawn ())
+ set_console_state_for_spawn ();
+
+ if (mode == _P_DETACH)
flags |= DETACHED_PROCESS;
if (mode != _P_OVERLAY)