From 881beea81de7a0877c64c01ba74de5e8a8d9dfd5 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sun, 1 Apr 2012 22:28:39 +0000 Subject: * dtable.cc (dtable::fixup_close): Define new function. (dtable::fixup_after_exec): Use fixup_close() and detect when it was not possible to open an inherited file handle. (dtable::fixup_after_fork): Defensively close any file handles which were not, for some reason, inheritable. * dtable.h: Make #pragma once. (dtable::fixup_close): Declare new function. * fhandler_console.cc (fhandler_console::set_unit): Set I/O handles to NULL when this function fails. --- winsup/cygwin/fhandler_console.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'winsup/cygwin/fhandler_console.cc') diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index 5be7111ff..7478eae19 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -141,18 +141,15 @@ fhandler_console::set_unit () fh_devices this_unit = dev (); fh_devices shared_unit = (fh_devices) shared_console_info->tty_min_state.getntty (); - created = false; devset = (shared_unit == this_unit || this_unit == FH_CONSOLE || this_unit == FH_CONIN || this_unit == FH_CONOUT || this_unit == FH_TTY) ? shared_unit : FH_ERROR; + created = false; } else if ((myself->ctty != -1 && !iscons_dev (myself->ctty)) || !(me = GetConsoleWindow ())) - { - created = false; - devset = FH_ERROR; - } + devset = FH_ERROR; else { created = true; @@ -166,6 +163,12 @@ fhandler_console::set_unit () dev ().parse (devset); if (devset != FH_ERROR) pc.file_attributes (FILE_ATTRIBUTE_NORMAL); + else + { + set_io_handle (NULL); + set_output_handle (NULL); + created = false; + } return created; } -- cgit v1.2.3