def preexec_function():
    os.setpgrp()
subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
    preexec_fn=preexec_function)
Making sure a Python script with subprocesses dies on SIGINT