How to stop SIGINT being passed to subprocess in python?

Viewed 5246

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 with Popen. is there some way to prevent passing this signal to the subprocess so that it also is not exited prematurely when the user presses ctrl-c?

3 Answers

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.

Related