Created
June 13, 2013 09:21
-
-
Save nobonobo/5772386 to your computer and use it in GitHub Desktop.
subprocessで子プロセス起こすとき、「, close_fds=True, preexec_fn=os.setsid」つけるとプロセスグループが独立するみたい。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
import os | |
import signal | |
from subprocess import Popen | |
cmd = ['python', '-c', 'import time; time.sleep(1); print "Hello."'] | |
if 0: | |
proc = Popen(cmd, close_fds=True, preexec_fn=os.setsid) | |
else: | |
proc = Popen(cmd) | |
os.killpg(os.getpgid(os.getpid()), signal.SIGTERM) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment