diff options
author | Christopher Faylor <me@cgf.cx> | 2003-12-12 20:46:03 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2003-12-12 20:46:03 +0000 |
commit | 9279515ae13bbaae37a1d9e8fc4beef0b7d77add (patch) | |
tree | d6650ed5d8f1705512b1e83da93f51d1a452848c /winsup | |
parent | fac0681d6cd0dea950ccf1ea79c0879fdf4321b4 (diff) | |
download | newlib-9279515ae13bbaae37a1d9e8fc4beef0b7d77add.zip newlib-9279515ae13bbaae37a1d9e8fc4beef0b7d77add.tar.gz newlib-9279515ae13bbaae37a1d9e8fc4beef0b7d77add.tar.bz2 |
* dtable.cc (dtable::delete_archetype): Add debugging.
(dtable::release): Move archetype deletion here.
(dtable::vfork_child_dup): Increment ctty usecount to catch later
close_all_files case in parent/child.
(dtable::vfork_child_fixup): Avoid using cygheap->foo where this should really
be using local references. Call close on archetyped handles since the handles
haven't had the noninherit flag set.
* fhandler_tty.cc (fhandler_tty_slave::close): Remove archetype deletion code.
Add defensive error message when DEBUGGING.
(fhandler_tty_common::set_close_on_exec): Use more robust method for checking
whether to set handles into noninherit if there is an archetype associated with
the fhandler.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/ChangeLog | 15 | ||||
-rw-r--r-- | winsup/cygwin/dtable.cc | 14 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_tty.cc | 13 |
3 files changed, 32 insertions, 10 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index fc9f1e7..8b178f5 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,20 @@ 2003-12-12 Christopher Faylor <cgf@redhat.com> + * dtable.cc (dtable::delete_archetype): Add debugging. + (dtable::release): Move archetype deletion here. + (dtable::vfork_child_dup): Increment ctty usecount to catch later + close_all_files case in parent/child. + (dtable::vfork_child_fixup): Avoid using cygheap->foo where this should + really be using local references. Call close on archetyped handles + since the handles haven't had the noninherit flag set. + * fhandler_tty.cc (fhandler_tty_slave::close): Remove archetype + deletion code. Add defensive error message when DEBUGGING. + (fhandler_tty_common::set_close_on_exec): Use more robust method for + checking whether to set handles into noninherit if there is an + archetype associated with the fhandler. + +2003-12-12 Christopher Faylor <cgf@redhat.com> + * dcrt0.cc (alloc_stack): Move _main_tls if stack is relocated. 2003-12-11 Christopher Faylor <cgf@redhat.com> diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index 70e52f4..c6c300b 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -188,6 +188,7 @@ dtable::delete_archetype (fhandler_base *fh) for (unsigned i = 0; i < narchetypes; i++) if (fh == archetypes[i]) { + debug_printf ("deleting archive element %d for %s", i, fh->get_name ()); if (i < --farchetype) archetypes[i] = archetypes[farchetype]; break; @@ -218,7 +219,10 @@ dtable::release (int fd) { if (fds[fd]->need_fixup_before ()) dec_need_fixup_before (); + fhandler_base *arch = fds[fd]->archetype; delete fds[fd]; + if (arch && !arch->usecount) + cygheap->fdtab.delete_archetype (arch); fds[fd] = NULL; } } @@ -697,6 +701,8 @@ dtable::vfork_child_dup () /* Remove impersonation */ cygheap->user.deimpersonate (); + if (cygheap->ctty) + cygheap->ctty->usecount++; for (size_t i = 0; i < size; i++) if (not_open (i)) @@ -746,16 +752,16 @@ dtable::vfork_child_fixup () fds = fds_on_hold; fhandler_base *fh; - for (int i = 0; i < (int) cygheap->fdtab.size; i++) - if ((fh = cygheap->fdtab[i]) != NULL) + for (int i = 0; i < (int) size; i++) + if ((fh = fds[i]) != NULL) { fh->clear_readahead (); - if (fh->get_close_on_exec ()) + if (!fh->archetype && fh->get_close_on_exec ()) release (i); else { fh->close (); - cygheap->fdtab.release (i); + release (i); } } diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 85a4cc7..60b12a9 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -616,15 +616,16 @@ fhandler_tty_slave::close () fhandler_console::open_fhs, archetype->usecount); if (--archetype->usecount) { +#ifdef DEBUGGING + if (archetype->usecount < 0) + system_printf ("usecount %d", archetype->usecount); +#endif termios_printf ("just exiting because archetype usecount is > 0"); return 0; } termios_printf ("closing last open %s handle", pc.dev.name); - fhandler_tty_slave *arch = (fhandler_tty_slave *) archetype; - int res = fhandler_tty_common::close (); - cygheap->fdtab.delete_archetype (arch); - return res; + return fhandler_tty_common::close (); } int @@ -910,7 +911,7 @@ fhandler_tty_slave::dup (fhandler_base *child) fhandler_console::open_fhs++; fhandler_tty_slave *arch = (fhandler_tty_slave *) archetype; *(fhandler_tty_slave *) child = *arch; - archetype->usecount++; + arch->usecount++; child->usecount = 0; myself->set_ctty (get_ttyp (), openflags, arch); termios_printf ("incremented open_fhs %d, archetype usecount %d", @@ -1331,7 +1332,7 @@ fhandler_pty_master::ptsname () void fhandler_tty_common::set_close_on_exec (int val) { - if (get_major () == DEV_TTYS_MAJOR) + if (archetype) set_close_on_exec_flag (val); else { |