# HG changeset patch # User Victor Scherba # Date 1391541083 -14400 # Tue Feb 04 23:11:23 2014 +0400 # Branch 2.7 # Node ID 2a8701ae65a9e5c4f7fb1bd0811033257b991c59 # Parent aed29f86bfdcb1817dedbc7eea944f262b3d9d1a Issue #20513: Filtered out CTRL_LOGOFF_EVENT and CTRL_SHUTDOWN_EVENT signals from PyCtrlHandler and ProcessingCtrlHandler diff -r aed29f86bfdc -r 2a8701ae65a9 Modules/_multiprocessing/multiprocessing.c --- a/Modules/_multiprocessing/multiprocessing.c Mon Feb 03 22:30:22 2014 +0200 +++ b/Modules/_multiprocessing/multiprocessing.c Tue Feb 04 23:11:23 2014 +0400 @@ -82,7 +82,14 @@ static BOOL WINAPI ProcessingCtrlHandler(DWORD dwCtrlType) { - SetEvent(sigint_event); + /* CTRL_LOGOFF_EVENT and CTRL_SHUTDOWN_EVENT signals + are received when process is windows service only. + Default windows handler do nothing on this signals. + On all other signals default windows handler causes ExitProcess. + */ + if (dwCtrlType != CTRL_LOGOFF_EVENT && dwCtrlType != CTRL_SHUTDOWN_EVENT) + SetEvent(sigint_event); + return FALSE; } diff -r aed29f86bfdc -r 2a8701ae65a9 Modules/timemodule.c --- a/Modules/timemodule.c Mon Feb 03 22:30:22 2014 +0200 +++ b/Modules/timemodule.c Tue Feb 04 23:11:23 2014 +0400 @@ -46,7 +46,13 @@ static HANDLE hInterruptEvent = NULL; static BOOL WINAPI PyCtrlHandler(DWORD dwCtrlType) { - SetEvent(hInterruptEvent); + /* CTRL_LOGOFF_EVENT and CTRL_SHUTDOWN_EVENT signals + are received when process is windows service only. + Default windows handler do nothing on this signals. + On all other signals default windows handler causes ExitProcess. + */ + if (dwCtrlType != CTRL_LOGOFF_EVENT && dwCtrlType != CTRL_SHUTDOWN_EVENT) + SetEvent(hInterruptEvent); /* allow other default handlers to be called. Default Python handler will setup the KeyboardInterrupt exception.