changeset 7632:2ef7061f13b4

Merge
author zgu
date Tue, 22 Jan 2013 11:54:16 -0800
parents edd23b35b1a5 (diff) 5ce621176715 (current diff)
children d754ef7b9352 5daaddd917a1
files src/os/windows/vm/os_windows.cpp
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/os/windows/vm/os_windows.cpp	Tue Jan 22 05:57:18 2013 -0800
+++ b/src/os/windows/vm/os_windows.cpp	Tue Jan 22 11:54:16 2013 -0800
@@ -1874,8 +1874,22 @@
       }
       return TRUE;
       break;
+    case CTRL_LOGOFF_EVENT: {
+      // Don't terminate JVM if it is running in a non-interactive session,
+      // such as a service process.
+      USEROBJECTFLAGS flags;
+      HANDLE handle = GetProcessWindowStation();
+      if (handle != NULL &&
+          GetUserObjectInformation(handle, UOI_FLAGS, &flags,
+            sizeof( USEROBJECTFLAGS), NULL)) {
+        // If it is a non-interactive session, let next handler to deal
+        // with it.
+        if ((flags.dwFlags & WSF_VISIBLE) == 0) {
+          return FALSE;
+        }
+      }
+    }
     case CTRL_CLOSE_EVENT:
-    case CTRL_LOGOFF_EVENT:
     case CTRL_SHUTDOWN_EVENT:
       os::signal_raise(SIGTERM);
       return TRUE;