< prev index next >

src/os/windows/vm/os_windows.cpp

Print this page




1962     void (*oldHandler)(int) = sigbreakHandler;
1963     sigbreakHandler = (void (*)(int)) handler;
1964     return (void*) oldHandler;
1965   } else {
1966     return (void*)::signal(signal_number, (void (*)(int))handler);
1967   }
1968 }
1969 
1970 void os::signal_raise(int signal_number) {
1971   raise(signal_number);
1972 }
1973 
1974 // The Win32 C runtime library maps all console control events other than ^C
1975 // into SIGBREAK, which makes it impossible to distinguish ^BREAK from close,
1976 // logoff, and shutdown events.  We therefore install our own console handler
1977 // that raises SIGTERM for the latter cases.
1978 //
1979 static BOOL WINAPI consoleHandler(DWORD event) {
1980   switch (event) {
1981   case CTRL_C_EVENT:
1982     if (is_error_reported()) {
1983       // Ctrl-C is pressed during error reporting, likely because the error
1984       // handler fails to abort. Let VM die immediately.
1985       os::die();
1986     }
1987 
1988     os::signal_raise(SIGINT);
1989     return TRUE;
1990     break;
1991   case CTRL_BREAK_EVENT:
1992     if (sigbreakHandler != NULL) {
1993       (*sigbreakHandler)(SIGBREAK);
1994     }
1995     return TRUE;
1996     break;
1997   case CTRL_LOGOFF_EVENT: {
1998     // Don't terminate JVM if it is running in a non-interactive session,
1999     // such as a service process.
2000     USEROBJECTFLAGS flags;
2001     HANDLE handle = GetProcessWindowStation();
2002     if (handle != NULL &&




1962     void (*oldHandler)(int) = sigbreakHandler;
1963     sigbreakHandler = (void (*)(int)) handler;
1964     return (void*) oldHandler;
1965   } else {
1966     return (void*)::signal(signal_number, (void (*)(int))handler);
1967   }
1968 }
1969 
1970 void os::signal_raise(int signal_number) {
1971   raise(signal_number);
1972 }
1973 
1974 // The Win32 C runtime library maps all console control events other than ^C
1975 // into SIGBREAK, which makes it impossible to distinguish ^BREAK from close,
1976 // logoff, and shutdown events.  We therefore install our own console handler
1977 // that raises SIGTERM for the latter cases.
1978 //
1979 static BOOL WINAPI consoleHandler(DWORD event) {
1980   switch (event) {
1981   case CTRL_C_EVENT:
1982     if (VMError::is_error_reported()) {
1983       // Ctrl-C is pressed during error reporting, likely because the error
1984       // handler fails to abort. Let VM die immediately.
1985       os::die();
1986     }
1987 
1988     os::signal_raise(SIGINT);
1989     return TRUE;
1990     break;
1991   case CTRL_BREAK_EVENT:
1992     if (sigbreakHandler != NULL) {
1993       (*sigbreakHandler)(SIGBREAK);
1994     }
1995     return TRUE;
1996     break;
1997   case CTRL_LOGOFF_EVENT: {
1998     // Don't terminate JVM if it is running in a non-interactive session,
1999     // such as a service process.
2000     USEROBJECTFLAGS flags;
2001     HANDLE handle = GetProcessWindowStation();
2002     if (handle != NULL &&


< prev index next >