aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2003-10-14 09:21:55 +0000
committerCorinna Vinschen <corinna@vinschen.de>2003-10-14 09:21:55 +0000
commitdb3137ccb5d3c7499a665d17abf84cf523146cbf (patch)
treeb1b538b50fca9ff69e4706d3cd975a302fce0453
parent2286046e474399b7d5a8ddd7b30ba96dd915a4e8 (diff)
downloadnewlib-db3137ccb5d3c7499a665d17abf84cf523146cbf.zip
newlib-db3137ccb5d3c7499a665d17abf84cf523146cbf.tar.gz
newlib-db3137ccb5d3c7499a665d17abf84cf523146cbf.tar.bz2
* exceptions.cc (ctrl_c_handler): Don't send SIGHUP on
CTRL_LOGOFF_EVENT to processes running in invisible Windows Stations. * window.cc (has_visible_window_station): New function. * winsup.h: Add declaration for has_visible_window_station.
-rw-r--r--winsup/cygwin/ChangeLog7
-rw-r--r--winsup/cygwin/exceptions.cc22
-rw-r--r--winsup/cygwin/window.cc20
-rw-r--r--winsup/cygwin/winsup.h2
4 files changed, 46 insertions, 5 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index f106d3f..c832d9f 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,10 @@
+2003-10-14 Corinna Vinschen <corinna@vinschen.de>
+
+ * exceptions.cc (ctrl_c_handler): Don't send SIGHUP on
+ CTRL_LOGOFF_EVENT to processes running in invisible Windows Stations.
+ * window.cc (has_visible_window_station): New function.
+ * winsup.h: Add declaration for has_visible_window_station.
+
2003-10-10 Christopher Faylor <cgf@redhat.com>
* fhandler_tty.cc (fhandler_tty_slave::open): Don't create a new window
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index 24b452b..65d57b3 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -12,6 +12,8 @@ details. */
#include <imagehlp.h>
#include <stdlib.h>
#include <setjmp.h>
+#include <wingdi.h>
+#include <winuser.h>
#include "exceptions.h"
#include "sync.h"
@@ -919,13 +921,23 @@ ctrl_c_handler (DWORD type)
return FALSE;
}
- if (myself->ctty != -1
- && (type == CTRL_CLOSE_EVENT || (!saw_close && type == CTRL_LOGOFF_EVENT)))
+ if (myself->ctty != -1)
{
if (type == CTRL_CLOSE_EVENT)
- saw_close = true;
- sig_send (NULL, SIGHUP);
- return FALSE;
+ {
+ saw_close = true;
+ sig_send (NULL, SIGHUP);
+ return FALSE;
+ }
+ if (!saw_close && type == CTRL_LOGOFF_EVENT)
+ {
+ /* Check if the process is actually associated with a visible
+ window station, one which actually represents a visible desktop.
+ If not, the CTRL_LOGOFF_EVENT doesn't concern this process. */
+ if (has_visible_window_station ())
+ sig_send (NULL, SIGHUP);
+ return FALSE;
+ }
}
/* If we are a stub and the new process has a pinfo structure, let it
diff --git a/winsup/cygwin/window.cc b/winsup/cygwin/window.cc
index ea9ed6e..3f94625 100644
--- a/winsup/cygwin/window.cc
+++ b/winsup/cygwin/window.cc
@@ -247,3 +247,23 @@ ualarm (useconds_t value, useconds_t interval)
return (otimer.it_value.tv_sec * 1000000) + otimer.it_value.tv_usec;
}
+bool
+has_visible_window_station (void)
+{
+ HWINSTA station_hdl;
+ USEROBJECTFLAGS uof;
+ DWORD len;
+
+ /* Check if the process is associated with a visible window station.
+ These are processes running on the local desktop as well as processes
+ running in terminal server sessions.
+ Processes running in a service session not explicitely associated
+ with the desktop (using the "Allow service to interact with desktop"
+ property) are running in an invisible window station. */
+ if ((station_hdl = GetProcessWindowStation ())
+ && GetUserObjectInformationA (station_hdl, UOI_FLAGS, &uof,
+ sizeof uof, &len)
+ && (uof.dwFlags & WSF_VISIBLE))
+ return true;
+ return false;
+}
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index 5a6f65d..745519e 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -200,6 +200,8 @@ void __stdcall close_all_files (void);
/* Invisible window initialization/termination. */
HWND __stdcall gethwnd (void);
+/* Check if running in a visible window station. */
+extern bool has_visible_window_station (void);
/* Globals that handle initialization of winsock in a child process. */
extern HANDLE wsock32_handle;