How to achieve desired results when using the subprocees Popen.send_signal(CTRL_C_EVENT) in Windows?

前端 未结 2 1776
[愿得一人]
[愿得一人] 2020-12-28 23:52

In python 2.7 in windows according to the documentation you can send a CTRL_C_EVENT (Python 2.7 Subprocess Popen.send_signal documentation). However when I tried it I did no

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-29 00:28

    try with

    win32api.GenerateConsoleCtrlEvent(CTRL_C_EVENT, pgroupid)
    

    or

    win32api.GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, pgroupid)
    

    references:

    http://docs.activestate.com/activepython/2.5/pywin3/win32process_CREATE_NEW_PROCESS_GROUP.html

    http://msdn.microsoft.com/en-us/library/ms683155%28v=vs.85%29.aspx

    read info about dwProcessGroupId, the groupid should be the same of the process id

提交回复
热议问题