From a448b8cf342529e055bf518fb181eacc7303c689 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sat, 6 Oct 2001 01:04:24 +0000 Subject: [PATCH] * fhandler.cc (fhandler_base::fork_fixup): Protect dup'ed handle and record it as non-inheritable for debugging purposes in case there is a subsequent fork or exec. * fhandler_tty.cc (fhandler_tty_common::fixup_after_fork): Allow fork_fixup to call ProtecHandle. --- winsup/cygwin/ChangeLog | 8 ++++++++ winsup/cygwin/fhandler.cc | 11 +++++++++-- winsup/cygwin/fhandler_tty.cc | 10 ++-------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index c0343ac59..ae8d57161 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,11 @@ +Fri Oct 5 21:01:14 2001 Christopher Faylor + + * fhandler.cc (fhandler_base::fork_fixup): Protect dup'ed handle and + record it as non-inheritable for debugging purposes in case there is a + subsequent fork or exec. + * fhandler_tty.cc (fhandler_tty_common::fixup_after_fork): Allow + fork_fixup to call ProtecHandle. + Fri Oct 5 14:22:47 2001 Christopher Faylor * path.cc (get_raw_device_number): Correct length arguments for diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index 6e2db18df..25e2aab83 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -1624,9 +1624,16 @@ fhandler_base::fork_fixup (HANDLE parent, HANDLE &h, const char *name) { if (!get_close_on_exec ()) debug_printf ("handle %p already opened", h); - else if (!DuplicateHandle (parent, h, hMainProc, &h, 0, !get_close_on_exec (), - DUPLICATE_SAME_ACCESS)) + else if (!DuplicateHandle (parent, h, hMainProc, &h, 0, 0, + DUPLICATE_SAME_ACCESS)) system_printf ("%s - %E, handle %s<%p>", get_name (), name, h); +#ifdef DEBUG + else + { + ProtectHandle1 (h, name); + setclexec_pid (h, 0); + } +#endif } void diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index a279180d2..0c1cf5c42 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -1143,15 +1143,9 @@ fhandler_tty_common::fixup_after_fork (HANDLE parent) if (ioctl_done_event) fork_fixup (parent, ioctl_done_event, "ioctl_done_event"); if (output_mutex) - { - fork_fixup (parent, output_mutex, "output_mutex"); - ProtectHandle (output_mutex); - } + fork_fixup (parent, output_mutex, "output_mutex"); if (input_mutex) - { - fork_fixup (parent, input_mutex, "input_mutex"); - ProtectHandle (input_mutex); - } + fork_fixup (parent, input_mutex, "input_mutex"); if (input_available_event) fork_fixup (parent, input_available_event, "input_available_event"); fork_fixup (parent, inuse, "inuse");