* 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:
Christopher Faylor
2012-04-01 22:28:39 +00:00
parent c4ee9311c2
commit 881beea81d
4 changed files with 47 additions and 14 deletions

View File

@ -9,6 +9,8 @@ This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#pragma once
/* Initial and increment values for cygwin's fd table */
#define NOFILE_INCR 32
/* Maximum size we allow expanding to. */
@ -54,6 +56,8 @@ public:
fhandler_base *dup_worker (fhandler_base *oldfh, int flags);
int extend (int howmuch);
void fixup_after_fork (HANDLE);
void fixup_close (size_t, fhandler_base *);
inline int not_open (int fd)
{
lock ();