changeset 4422:21b0918ed779

6871190: Don't terminate JVM if it is running in a non-interactive session Summary: Don't handle CTRL_LOGOFF_EVENT event when the process is running in a non-interactive session Reviewed-by: ctornqvi, acorn
author zgu
date Tue, 22 Jan 2013 14:27:41 -0500
parents 9a5777cc2847
children fed67a49fd2c
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	Thu Jan 24 11:40:59 2013 -0800
+++ b/src/os/windows/vm/os_windows.cpp	Tue Jan 22 14:27:41 2013 -0500
@@ -1888,8 +1888,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;