[New-bugs-announce] [issue20513] Script interruption on logoff from 0 session under Win2003 and earlier
report at bugs.python.org
Tue Feb 4 20:03:28 CET 2014
New submission from Victor Scherba:
To get the bug:
1. Windows Server 2003 (same bug should be under earlier versions: XP, 2000, ...).
2. Any Windows service should spawn process with Python script.
3. Py script should stay into time.sleep.
4. Any Windows user should login in console session 0.
5. Bug: when this user logoff, script interrupts.
To repeat the bug simply you could use srvany which spawn: python.exe -c "import time; time.sleep(10000)".
There is problem in cpython/Modules/timemodule.c in PyCtrlHandler.
Before logoff Windows broadcasts to all services and its children CTRL_LOGOFF_EVENT signal. But PyCtrlHandler doesn't filter it out by dwCtrlType and always sets hInterruptEvent. This forces script interruption.
CTRL_SHUTDOWN_EVENT also should be filtered out. CTRL_SHUTDOWN_EVENT broacasted to all services before Windows shutdown. But after it has been handled, other process can block or pause shutdowning.
Default Windows console control handler does not call ExitProcess when processing the CTRL_LOGOFF_EVENT and CTRL_SHUTDOWN_EVENT signals. See more at http://msdn.microsoft.com/en-us/library/windows/desktop/ms683242(v=vs.85).aspx
On Win Vista and higher bug not presents. Impossible to login to session 0 because of session 0 isolation.
Patch attached. There is same fix in cpython/Modules/_multiprocessing/multiprocessing.c
components: Extension Modules, Windows
title: Script interruption on logoff from 0 session under Win2003 and earlier
versions: Python 2.7
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce