From 0855f12de83ba41bb5376811e00cf7606aed4723 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Sun, 20 Jun 2010 16:37:17 -0400 Subject: [PATCH] [python] Call background programs with stdin=/dev/null. --- alternative_wmiircs/python/pygmi/util.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/alternative_wmiircs/python/pygmi/util.py b/alternative_wmiircs/python/pygmi/util.py index a5fe7d44..66a34b14 100644 --- a/alternative_wmiircs/python/pygmi/util.py +++ b/alternative_wmiircs/python/pygmi/util.py @@ -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: