mirror of https://github.com/0intro/wmii
[python] Call background programs with stdin=/dev/null.
This commit is contained in:
parent
262778dccc
commit
0855f12de8
|
@ -11,9 +11,10 @@ def _():
|
||||||
|
|
||||||
def call(*args, **kwargs):
|
def call(*args, **kwargs):
|
||||||
background = kwargs.pop('background', False)
|
background = kwargs.pop('background', False)
|
||||||
|
stdin = subprocess.PIPE if not background else open('/dev/null', 'r')
|
||||||
pipe = subprocess.PIPE if not background else None
|
pipe = subprocess.PIPE if not background else None
|
||||||
input = kwargs.pop('input', 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),
|
preexec_fn=lambda: signal.signal(signal.SIGPIPE, signal.SIG_DFL),
|
||||||
cwd=os.environ['HOME'], close_fds=True, **kwargs)
|
cwd=os.environ['HOME'], close_fds=True, **kwargs)
|
||||||
if not background:
|
if not background:
|
||||||
|
|
Loading…
Reference in New Issue