diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-05-02 12:58:33 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-05-02 18:22:03 +0200 |
commit | d7823e0266d38dd83d7f824f6bafb3898ccbca75 (patch) | |
tree | f4d220f6382e9c83f4e8bb80c085d99368ae031b /sal/osl | |
parent | da50aaff5324661cbc7b4513ba249d9ed58f3626 (diff) |
tdf#155122: implement CtrlHandler on Windows
Change-Id: Ia766db91030528c320a27a2d608bd0ec0a34f31b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151261
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sal/osl')
-rw-r--r-- | sal/osl/w32/signal.cxx | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sal/osl/w32/signal.cxx b/sal/osl/w32/signal.cxx index dcb05beae097..52d47da86b6c 100644 --- a/sal/osl/w32/signal.cxx +++ b/sal/osl/w32/signal.cxx @@ -33,12 +33,43 @@ namespace { long WINAPI signalHandlerFunction(LPEXCEPTION_POINTERS lpEP); +// Similar to SIGINT handler in sal/osl/unx/signal.cxx +BOOL WINAPI CtrlHandlerFunction(DWORD dwCtrlType) +{ + switch (dwCtrlType) + { + case CTRL_C_EVENT: + case CTRL_BREAK_EVENT: + case CTRL_CLOSE_EVENT: + switch (oslSignalInfo Info{ osl_Signal_Terminate }; callSignalHandler(&Info)) + { + case osl_Signal_ActCallNextHdl: + break; // Fall through to call the next handler + + case osl_Signal_ActAbortApp: + abort(); + break; + + case osl_Signal_ActKillApp: + _exit(255); + break; + + default: + return TRUE; // do not call the next handler + } + [[fallthrough]]; + default: + return FALSE; // call the next handler + } +} + LPTOP_LEVEL_EXCEPTION_FILTER pPreviousHandler = nullptr; } bool onInitSignal() { pPreviousHandler = SetUnhandledExceptionFilter(signalHandlerFunction); + SetConsoleCtrlHandler(CtrlHandlerFunction, TRUE); WerAddExcludedApplication(L"SOFFICE.EXE", FALSE); @@ -47,6 +78,7 @@ bool onInitSignal() bool onDeInitSignal() { + SetConsoleCtrlHandler(CtrlHandlerFunction, FALSE); SetUnhandledExceptionFilter(pPreviousHandler); return false; |