summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/syscalls.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2003-12-11 06:12:41 +0000
committerChristopher Faylor <me@cgf.cx>2003-12-11 06:12:41 +0000
commit8e10c4311f9612951c82da5e844d51d985552d65 (patch)
tree23808644eb736e80e3160f30a07fe0357babe5f2 /winsup/cygwin/syscalls.cc
parent3f23411449cf414d447bf793a20f42ed3f8e5061 (diff)
downloadcygnal-8e10c4311f9612951c82da5e844d51d985552d65.tar.gz
cygnal-8e10c4311f9612951c82da5e844d51d985552d65.tar.bz2
cygnal-8e10c4311f9612951c82da5e844d51d985552d65.zip
* cygheap.h (cygheap_types): Add HEAP_ARCHETYPES.
(init_cheap::ctty): Change to pointer. * dtable.h (dtable::find_archetype): Declare new function. (dtable::add_archetype): Declare new function. (dtable::delete_archetype): Declare new function. (dtable::narchetypes): Declare. (dtable::farchetypes): Declare. (dtable::initial_archetype_size): Declare. (dtable::dtable): Initialize new fields. (dtable::initial_archetype_size): Declare. * dtable.cc (dtable::find_archetype): Define new function. (dtable::add_archetype): Define new function. (dtable::delete_archetype): Define new function. (dtable::initial_archetype_size): Define. * fhandler.h (fhandler_base::archetype): Declare. (fhandler_base::usecount): Declare. * fhandler.cc (fhandler_base::fhandler_base): Initialize new fields. * fhandler_console.cc (fhandler_console::get_tty_stuff): Pass NULL to third argument of set_ctty. * fhandler_tty.cc (fhandler_tty_slave::open): Accommodate new archetype method to create only one instance of a tty. (fhandler_tty_slave::close): Don't close handles unless archetype usecount is zero. When that happens, close archetype too. (fhandler_tty_slave::dup): Just copy archetype. Set use count appropriately. Set ctty, if appropriate. (fhandler_tty_common::dup): Remove slave considerations. (fhandler_tty_common::set_close_on_exec): Remove cygheap->ctty considerations. * pinfo.cc (_pinfo::set_ctty): Accommodate new archetype methods. * pinfo.h (_pinfo::set_ctty): Make third argument explicit. * syscalls.cc (close_all_files): Decrement controlling tty use count before closing all handles to allow controlling tty to be closed. Remove previous controlling tty considerations.
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r--winsup/cygwin/syscalls.cc17
1 files changed, 12 insertions, 5 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 1a77c360f..992218271 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -89,6 +89,12 @@ close_all_files (void)
{
SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "close_all_files");
+ if (cygheap->ctty)
+ {
+ debug_printf ("decrementing ctty usecount");
+ cygheap->ctty->usecount--;
+ }
+
fhandler_base *fh;
for (int i = 0; i < (int) cygheap->fdtab.size; i++)
if ((fh = cygheap->fdtab[i]) != NULL)
@@ -97,9 +103,6 @@ close_all_files (void)
cygheap->fdtab.release (i);
}
- if (cygheap->ctty.get_io_handle ())
- cygheap->ctty.fhandler_tty_common::close ();
-
ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "close_all_files");
user_shared->delqueue.process_queue ();
}
@@ -320,10 +323,14 @@ setsid (void)
myself->ctty = -1;
myself->sid = getpid ();
myself->pgid = getpid ();
- if (cygheap->ctty.get_io_handle ())
- cygheap->ctty.fhandler_tty_common::close ();
syscall_printf ("sid %d, pgid %d, ctty %d, open_fhs %d", myself->sid,
myself->pgid, myself->ctty, fhandler_console::open_fhs);
+ if (cygheap->ctty)
+ {
+ if (!--cygheap->ctty->usecount)
+ cygheap->ctty->close ();
+ cygheap->ctty = NULL;
+ }
return myself->sid;
}