How to stop SIGINT being passed to subprocess in python?

后端 未结 3 602
野性不改
野性不改 2021-02-04 06:33

My python script intercepts the SIGINT signal with the signal process module to prevent premature exit, but this signal is passed to a subprocess that I open wi

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-04 07:15

    For python 2 codebase: subprocess is broken.

    The right thing is

    import subprocess32 as subprocess
    

    See subprocess32

    This is a backport of the Python 3 subprocess module for use on Python 2. This code has not been tested on Windows or other non-POSIX platforms.

提交回复
热议问题