我试过这样的事情:
subprocess.Popen(['nohup', 'my_command'],
stdout=open('/dev/null', 'w'),
stderr=open('logfile.log', 'a'))
Run Code Online (Sandbox Code Playgroud)
如果父脚本正常退出,则此方法有效,但如果我终止脚本(Ctrl-C),则所有子进程也将被终止.有办法避免这种情况吗?
我关心的平台是OS X和Linux,使用的是Python 2.6 和 Python 2.7.