From f4c566233f28f747fce3c21031f6f3d47a0a6643 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Fri, 6 May 2011 20:12:20 +0000 Subject: [PATCH] * fhandler.cc (fhandler_base::dup): Avoid duping a handle when an fhandler has an archetype. * fhandler_console.cc (fhandler_console::invisible_console): Move to the top. (fhandler_console::set_close_on_exec): Don't set close-on-exec on handle since it's an archetype and you don't know how many things could be using it. --- winsup/cygwin/ChangeLog | 10 ++++++++++ winsup/cygwin/fhandler.cc | 2 +- winsup/cygwin/fhandler_console.cc | 7 +++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index d04e8c2ad..952ec86c5 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,13 @@ +2011-05-06 Christopher Faylor + + * fhandler.cc (fhandler_base::dup): Avoid duping a handle when an + fhandler has an archetype. + * fhandler_console.cc (fhandler_console::invisible_console): Move to + the top. + (fhandler_console::set_close_on_exec): Don't set close-on-exec on + handle since it's an archetype and you don't know how many things could + be using it. + 2011-05-06 Christopher Faylor * fhandler.h (fhandler_dev_dsp): Cosmetic change. diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index 304feed63..f96d537ef 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -1246,7 +1246,7 @@ fhandler_base::dup (fhandler_base *child) debug_printf ("in fhandler_base dup"); HANDLE nh; - if (!nohandle ()) + if (!nohandle () && !archetype) { if (!DuplicateHandle (GetCurrentProcess (), get_handle (), GetCurrentProcess (), &nh, diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index 8fe4414cc..55e9b3ee8 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -56,6 +56,8 @@ const unsigned fhandler_console::MAX_WRITE_CHARS = 16384; static console_state NO_COPY *shared_console_info; +bool NO_COPY fhandler_console::invisible_console; + dev_console NO_COPY *fhandler_console::dev_state; static void @@ -2103,8 +2105,7 @@ fhandler_console::igncr_enabled () void fhandler_console::set_close_on_exec (bool val) { - fhandler_base::set_close_on_exec (val); - set_no_inheritance (output_handle, val); + close_on_exec (val); } void __stdcall @@ -2123,8 +2124,6 @@ fhandler_console::fixup_after_fork_exec (bool execing) get_tty_stuff (); } -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 WINSTA_ALL_ACCESS