diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 73d92b656..add3892f0 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,14 @@ +2006-01-07 Christopher Faylor + + * fhandler.h (set_console_state_for_spawn): Eliminate argument from + declaration. + * fhandler.cc (set_console_state_for_spawn): Eliminate argument from + definition. Always check for invisible console. + (fhandler_console::need_invisible): Don't do anything if the windows + station is already not visible. + * spawn.cc (spawn_guts): Accommodate change of argument to + set_console_state_for_spawn. + 2006-01-05 Christopher Faylor * sigproc.cc (no_signals_available): Use existence of signal thread diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 86c318156..a7c759bf1 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -1365,6 +1365,6 @@ class select_stuff device_specific_mailslot (0) {} }; -void __stdcall set_console_state_for_spawn (bool) __attribute__ ((regparm (1))); +void __stdcall set_console_state_for_spawn (); #endif /* _FHANDLER_H_ */ diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index a86dc7af5..a82792131 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -146,7 +146,7 @@ tty_list::get_tty (int n) void __stdcall set_console_state_for_spawn (bool noncygwin_process) { - if (noncygwin_process && fhandler_console::need_invisible ()) + if (fhandler_console::need_invisible ()) return; HANDLE h = CreateFile ("CONIN$", GENERIC_READ, FILE_SHARE_WRITE, @@ -1825,6 +1825,9 @@ fhandler_console::fixup_after_fork_exec (bool execing) bool NO_COPY fhandler_console::invisible_console; +// #define WINSTA_ACCESS (WINSTA_READATTRIBUTES | STANDARD_RIGHTS_READ | STANDARD_RIGHTS_WRITE | WINSTA_CREATEDESKTOP | WINSTA_EXITWINDOWS) +#define WINSTA_ACCESS STANDARD_RIGHTS_READ + bool fhandler_console::need_invisible () { @@ -1854,25 +1857,39 @@ fhandler_console::need_invisible () process using setsid: bash -lc "setsid rxvt". */ h = horig = GetProcessWindowStation (); - if (myself->ctty == -1) + + USEROBJECTFLAGS oi; + DWORD len; + if (!horig + || !GetUserObjectInformation (horig, UOI_FLAGS, &oi, sizeof (oi), &len) + || !(oi.dwFlags & WSF_VISIBLE)) { - if (!(h = CreateWindowStation (NULL, 0, WINSTA_ALL_ACCESS, &sec_all_nih))) - h = CreateWindowStation ("CygwinInvisible", 0, WINSTA_ALL_ACCESS, - &sec_all_nih); - termios_printf ("CreateWindowStation(\"CygwinInvisible\", %p), %E", h); - if (h) - { - b = SetProcessWindowStation (h); - termios_printf ("SetProcessWindowStation %d, %E", b); - } + b = true; + debug_printf ("window station is not visible"); + invisible_console = true; + } + else + { + if (myself->ctty == -1 && oi.dwFlags & WSF_VISIBLE) + { + h = CreateWindowStation (NULL, 0, WINSTA_ACCESS, NULL); + termios_printf ("CreateWindowStation(NULL, %p), %E", h); + if (h) + { + b = SetProcessWindowStation (h); + termios_printf ("SetProcessWindowStation %d, %E", b); + } + } + b = AllocConsole (); /* will cause flashing if CreateWorkstation + failed */ + debug_printf ("h %p, horig %p, flags %p", h, horig, oi.dwFlags); + if (horig && h && h != horig && SetProcessWindowStation (horig)) + { + CloseWindowStation (h); + } + termios_printf ("%d = AllocConsole (), %E", b); + invisible_console = true; } - b = AllocConsole (); /* will cause flashing if CreateWorkstation - failed */ - debug_printf ("h (%p), horig (%p)", h, horig); - if (horig && h && h != horig && SetProcessWindowStation (horig)) - CloseWindowStation (h); - termios_printf ("%d = AllocConsole (), %E", b); - invisible_console = true; } debug_printf ("invisible_console %d", invisible_console); diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 7919ed4b2..d1e6ce869 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -617,7 +617,7 @@ spawn_guts (const char * prog_arg, const char *const *argv, else system_printf ("duplicate to pid_handle failed, %E"); if (mode != _P_DETACH) - set_console_state_for_spawn (!real_path.iscygexec ()); + set_console_state_for_spawn (); } /* Some file types (currently only sockets) need extra effort in the parent