[python] Call background programs with stdin=/dev/null.

This commit is contained in:
Kris Maglione 2010-06-20 16:37:17 -04:00
parent 262778dccc
commit 0855f12de8
1 changed files with 2 additions and 1 deletions

View File

@ -11,9 +11,10 @@ def _():
def call(*args, **kwargs):
background = kwargs.pop('background', False)
stdin = subprocess.PIPE if not background else open('/dev/null', 'r')
pipe = subprocess.PIPE if not background else None
input = kwargs.pop('input', None)
p = subprocess.Popen(args, stdin=pipe, stdout=pipe, stderr=pipe,
p = subprocess.Popen(args, stdin=stdin, stdout=pipe, stderr=pipe,
preexec_fn=lambda: signal.signal(signal.SIGPIPE, signal.SIG_DFL),
cwd=os.environ['HOME'], close_fds=True, **kwargs)
if not background: