Mercurial > hg > truffle
diff src/os/windows/vm/os_windows.cpp @ 7631:edd23b35b1a5
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 | 4daebd4cc1dd |
children | 2ef7061f13b4 |
line wrap: on
line diff
--- a/src/os/windows/vm/os_windows.cpp Mon Jan 14 15:17:47 2013 +0100 +++ b/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;