Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2012-04-02 02:28:39 +0400
committerChristopher Faylor <me@cgf.cx>2012-04-02 02:28:39 +0400
commit881beea81de7a0877c64c01ba74de5e8a8d9dfd5 (patch)
treec09074c640b7e836e09e2333d55675b4f4b6baf6 /winsup/cygwin/fhandler_console.cc
parentc4ee9311c2c8cd01cadaa411900d284ba0fd2bdb (diff)
* 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.
Diffstat (limited to 'winsup/cygwin/fhandler_console.cc')
-rw-r--r--winsup/cygwin/fhandler_console.cc13
1 files changed, 8 insertions, 5 deletions
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;
}