From df04ae29b258b89bbd4991bd862a03ac56430e4e Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sat, 26 Jul 2003 04:53:59 +0000 Subject: * 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. --- winsup/cygwin/exceptions.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'winsup/cygwin/exceptions.cc') diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 3c8bf39c9..e7c304185 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -923,25 +923,29 @@ 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 /* Don't send a signal. Only NT service applications and their child - processes will receive this event and the services typically already + processes will receive this event and the services typically already handle the shutdown action when getting the SERVICE_CONTROL_SHUTDOWN control message. */ sig_send (NULL, SIGTERM); #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; } -- cgit v1.2.3