Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-07-26 04:10:52 +0400
committerChristopher Faylor <me@cgf.cx>2001-07-26 04:10:52 +0400
commit0cc642a5f1b2121b4a451dfcd25fd98384f694c9 (patch)
tree4250d61796a5bcaa3304a691c988e7430c0e6d81 /winsup/cygwin/dtable.cc
parent811bf2902df2465fef297c82be03ed5c1fcbd0fa (diff)
* syscalls.cc (setsid): Detach process from its console if the current
controlling tty is the console and already closed. * dtable.h (class dtable): Add members to count descriptors referring to the console. * dtable.cc (dtable::dec_console_fds): New function to detach process from its console. (dtable::release): Decrement the counter of console descriptors. (dtable::build_fhandler): Increment it. * exception.cc (ctrl_c_handler): Send SIGTERM to myself when catch CTRL_SHUTDOWN_EVENT.
Diffstat (limited to 'winsup/cygwin/dtable.cc')
-rw-r--r--winsup/cygwin/dtable.cc19
1 files changed, 16 insertions, 3 deletions
diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
index a5477eb98..cc16fdada 100644
--- a/winsup/cygwin/dtable.cc
+++ b/winsup/cygwin/dtable.cc
@@ -1,6 +1,6 @@
/* dtable.cc: file descriptor support.
- Copyright 1996, 1997, 1998, 1999, 2000 Cygnus Solutions.
+ Copyright 1996, 1997, 1998, 1999, 2000, 2001 Cygnus Solutions.
This file is part of Cygwin.
@@ -51,6 +51,13 @@ set_std_handle (int fd)
SetStdHandle (std_consts[fd], cygheap->fdtab[fd]->get_output_handle ());
}
+void
+dtable::dec_console_fds ()
+{
+ if (console_fds > 0 && !--console_fds && myself->ctty != TTY_CONSOLE)
+ FreeConsole ();
+}
+
int
dtable::extend (int howmuch)
{
@@ -146,8 +153,13 @@ dtable::release (int fd)
{
if (!not_open (fd))
{
- if ((fds[fd]->get_device () & FH_DEVMASK) == FH_SOCKET)
- dec_need_fixup_before ();
+ switch (fds[fd]->get_device ())
+ {
+ case FH_SOCKET:
+ dec_need_fixup_before ();
+ case FH_CONSOLE:
+ dec_console_fds ();
+ }
delete fds[fd];
fds[fd] = NULL;
}
@@ -261,6 +273,7 @@ dtable::build_fhandler (int fd, DWORD dev, const char *name, int unit)
case FH_CONIN:
case FH_CONOUT:
fh = new (buf) fhandler_console (name);
+ inc_console_fds ();
break;
case FH_PTYM:
fh = new (buf) fhandler_pty_master (name);