* exceptions.cc (ctrl_c_handler): Send SIGHUP when events occur only if there

is a tty associated with the process.  Send SIGHUP on CTRL_LOGOFF_EVENT.
* fhandler_tty.cc (fhandler_tty_slave::open): Adjust console open handle
counter regardless of whether this is a pty or tty.
(fhandler_tty_slave::open): Ditto.
(fhandler_tty_slave::dup): Ditto.
(fhandler_tty_common::set_close_on_exec): Ditto.
(fhandler_tty_master::init_console): Decrement console open handle counter
after init since it will now be handled by all tty open.
* syscalls.cc (setsid): Rework debugging output slightly.
This commit is contained in:
Christopher Faylor 2003-07-26 04:53:59 +00:00
parent ddb6762155
commit df04ae29b2
14 changed files with 231 additions and 223 deletions

View File

@ -1,3 +1,18 @@
2003-07-26 Christopher Faylor <cgf@redhat.com>
* exceptions.cc (ctrl_c_handler): Send SIGHUP when events occur only if
there is a tty associated with the process. Send SIGHUP on
CTRL_LOGOFF_EVENT.
* fhandler_tty.cc (fhandler_tty_slave::open): Adjust console open
handle counter regardless of whether this is a pty or tty.
(fhandler_tty_slave::open): Ditto.
(fhandler_tty_slave::dup): Ditto.
(fhandler_tty_common::set_close_on_exec): Ditto.
(fhandler_tty_master::init_console): Decrement console open handle
counter after init since it will now be handled by all tty open.
* syscalls.cc (setsid): Rework debugging output slightly.
2003-07-25 Christopher Faylor <cgf@redhat.com>
* configure.in: Use 'install-sh -c'.

View File

@ -923,12 +923,12 @@ setup_handler (int sig, void *handler, struct sigaction& siga)
static BOOL WINAPI
ctrl_c_handler (DWORD type)
{
if (type == CTRL_LOGOFF_EVENT)
return TRUE;
static bool saw_close;
/* Return FALSE to prevent an "End task" dialog box from appearing
for each Cygwin process window that's open when the computer
is shut down or console window is closed. */
if (type == CTRL_SHUTDOWN_EVENT)
{
#if 0
@ -940,8 +940,12 @@ ctrl_c_handler (DWORD type)
#endif
return FALSE;
}
if (type == CTRL_CLOSE_EVENT)
if (myself->ctty != -1
&& (type == CTRL_CLOSE_EVENT || (!saw_close && type == CTRL_LOGOFF_EVENT)))
{
if (type == CTRL_CLOSE_EVENT)
saw_close = true;
sig_send (NULL, SIGHUP);
return FALSE;
}

View File

@ -555,9 +555,7 @@ fhandler_tty_slave::open (path_conv *, int flags, mode_t)
set_output_handle (to_master_local);
set_open_status ();
if (!output_done_event)
{
if (fhandler_console::open_fhs++ == 0
if (fhandler_console::open_fhs++ == 0 && !output_done_event
&& wincap.pty_needs_alloc_console ())
{
BOOL b;
@ -573,7 +571,6 @@ fhandler_tty_slave::open (path_conv *, int flags, mode_t)
termios_printf ("%d = AllocConsole ()", b);
}
termios_printf ("incremented open_fhs %d", fhandler_console::open_fhs);
}
termios_printf ("tty%d opened", ttynum);
return 1;
@ -581,13 +578,10 @@ fhandler_tty_slave::open (path_conv *, int flags, mode_t)
int
fhandler_tty_slave::close ()
{
if (!output_done_event)
{
if (!--fhandler_console::open_fhs && myself->ctty == -1)
FreeConsole ();
termios_printf ("decremented open_fhs %d", fhandler_console::open_fhs);
}
return fhandler_tty_common::close ();
}
@ -854,12 +848,9 @@ fhandler_tty_slave::read (void *ptr, size_t& len)
int
fhandler_tty_slave::dup (fhandler_base *child)
{
if (!output_done_event)
{
fhandler_console::open_fhs++;
termios_printf ("incremented open_fhs %d", fhandler_console::open_fhs);
}
return fhandler_tty_common::dup (child);
}
@ -1252,12 +1243,9 @@ fhandler_tty_common::set_close_on_exec (int val)
void
fhandler_tty_slave::fixup_after_fork (HANDLE parent)
{
if (!output_done_event)
{
fhandler_console::open_fhs++;
termios_printf ("incremented open_fhs %d", fhandler_console::open_fhs);
}
fhandler_tty_common::fixup_after_fork (parent);
}
@ -1317,6 +1305,7 @@ fhandler_tty_master::init_console ()
return -1;
console->init (INVALID_HANDLE_VALUE, GENERIC_READ | GENERIC_WRITE, O_BINARY);
fhandler_console::open_fhs--; /* handled when individual fds are opened */
console->set_r_no_interrupt (1);
return 0;
}

View File

@ -284,14 +284,14 @@ setsid (void)
{
if (myself->ctty >= 0 && fhandler_console::open_fhs <= 0)
{
syscall_printf ("open_fhs %d, freeing console",
fhandler_console::open_fhs);
syscall_printf ("freeing console");
FreeConsole ();
}
myself->ctty = -1;
myself->sid = getpid ();
myself->pgid = getpid ();
syscall_printf ("sid %d, pgid %d, ctty %d", myself->sid, myself->pgid, myself->ctty);
syscall_printf ("sid %d, pgid %d, ctty %d, open_fhs %d", myself->sid,
myself->pgid, myself->ctty, fhandler_console::open_fhs);
return myself->sid;
}