Eryk Sun added the comment:

You can send CTRL_C_EVENT to a process group. But it requires the group leader 
to manually enable Ctrl+C handling. Initially it's disabled when creating a 
process with CREATE_NEW_PROCESS_GROUP. 

The attached script demonstrates sending CTRL_C_EVENT to a process group. The 
child process is the group leader, so CTRL+C event processing has to be 
manually enabled in it by calling SetConsoleCtrlHandler(NULL, FALSE). This flag 
gets inherited by the grandchild process. Example output:

    Process 0300: created process 0464
    Process 0464: created process 0456
    Process 0464: received CTRL+C
    Process 0456: received CTRL+C

That said, given that MSDN [erroneously] claims that this isn't possible, 
probably the subprocess docs should only mention sending CTRL_BREAK_EVENT.

----------
nosy: +eryksun
versions: +Python 3.4, Python 3.5, Python 3.6 -Python 3.2, Python 3.3
Added file: http://bugs.python.org/file41242/proc_group_ctrl_c.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue13368>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to