* 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.
This commit is contained in:
Christopher Faylor
2001-07-26 00:10:52 +00:00
parent 811bf2902d
commit 0cc642a5f1
5 changed files with 51 additions and 10 deletions

View File

@@ -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);