How to stop python from propagating signals to subprocesses?

前端 未结 5 1632
情歌与酒
情歌与酒 2020-12-17 08:51

I\'m using python to manage some simulations. I build the parameters and run the program using:

pipe = open(\'/dev/null\', \'w\')
pid = subprocess.Popen(shle         


        
5条回答
  •  难免孤独
    2020-12-17 09:40

    Combining some of other answers that will do the trick - no signal sent to main app will be forwarded to the subprocess.

    import os
    from subprocess import Popen
    
    def preexec(): # Don't forward signals.
        os.setpgrp()
    
    Popen('whatever', preexec_fn = preexec)
    

提交回复
热议问题