# HG changeset patch # User zgu # Date 1358882861 18000 # Node ID 27d5f33652c7b91500f258a16497d7ac35ad921a # Parent 8e6b5694267f77f98c6f06781b13b3faf9c1fc8d 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 diff -r 8e6b5694267f -r 27d5f33652c7 hotspot/src/os/windows/vm/os_windows.cpp --- a/hotspot/src/os/windows/vm/os_windows.cpp Mon Jan 14 15:17:47 2013 +0100 +++ b/hotspot/src/os/windows/vm/os_windows.cpp Tue Jan 22 14:27:41 2013 -0500 @@ -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;