* fhandler.h (fhandler_tty_slave::archetype): Make public.

(report_tty_counts): New macro.  Use throughout for reporting tty use counts.
* dtable.cc (dtable::vfork_child_dup): Add debugging output for usecount
increment.  Increment open_fhs if appropriate.
(dtable::vfork_parent_restore): "Close" artificially bumped ctty.
(dtable::vfork_child_fixup): Close ctty since it was bumped prior to vfork.
Save open_fhs around close since the closing of these handles has no effect on
the console.
* fhandler_tty.cc (fhandler_tty_slave::open): Reorganize calls to allow for
easier tracking of usecount modification.
(fhandler_tty_slave::open): Ditto.
This commit is contained in:
Christopher Faylor
2003-12-27 17:41:17 +00:00
parent fe861ce934
commit e97377932b
6 changed files with 47 additions and 16 deletions

View File

@@ -31,6 +31,7 @@ details. */
#include "dtable.h"
#include "cygheap.h"
#include "ntdll.h"
#include "tty.h"
static const NO_COPY DWORD std_consts[] = {STD_INPUT_HANDLE, STD_OUTPUT_HANDLE,
STD_ERROR_HANDLE};
@@ -701,7 +702,11 @@ dtable::vfork_child_dup ()
/* Remove impersonation */
cygheap->user.deimpersonate ();
if (cygheap->ctty)
cygheap->ctty->usecount++;
{
cygheap->ctty->usecount++;
fhandler_console::open_fhs++;
report_tty_counts (cygheap->ctty, "vfork dup", "incremented ", "");
}
for (size_t i = 0; i < size; i++)
if (not_open (i))
@@ -737,6 +742,9 @@ dtable::vfork_parent_restore ()
fds_on_hold = NULL;
cfree (deleteme);
if (cygheap->ctty)
cygheap->ctty->close ();
ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "restore");
return;
}
@@ -750,6 +758,7 @@ dtable::vfork_child_fixup ()
fhandler_base **saveme = fds;
fds = fds_on_hold;
int old_open_fhs = fhandler_console::open_fhs;
fhandler_base *fh;
for (int i = 0; i < (int) size; i++)
if ((fh = fds[i]) != NULL)
@@ -764,6 +773,10 @@ dtable::vfork_child_fixup ()
}
}
fhandler_console::open_fhs = old_open_fhs;
if (cygheap->ctty)
cygheap->ctty->close ();
fds = saveme;
cfree (fds_on_hold);
fds_on_hold = NULL;