* 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.
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user