mirror of
https://github.com/0intro/wmii
synced 2024-11-22 05:42:05 +03:00
[pygmi] Don't launch background processes with IO pipes. Restore SIGPIPE. (Closes issue #176)
This commit is contained in:
parent
208db05798
commit
9adfeea6c2
@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import signal
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
import pygmi
|
import pygmi
|
||||||
@ -10,10 +11,11 @@ def _():
|
|||||||
|
|
||||||
def call(*args, **kwargs):
|
def call(*args, **kwargs):
|
||||||
background = kwargs.pop('background', False)
|
background = kwargs.pop('background', False)
|
||||||
|
pipe = subprocess.PIPE if not background else None
|
||||||
input = kwargs.pop('input', None)
|
input = kwargs.pop('input', None)
|
||||||
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
p = subprocess.Popen(args, stdin=pipe, stdout=pipe, stderr=pipe,
|
||||||
stderr=subprocess.PIPE, cwd=os.environ['HOME'],
|
preexec_fn=lambda: signal.signal(signal.SIGPIPE, signal.SIG_DFL),
|
||||||
close_fds=True, **kwargs)
|
cwd=os.environ['HOME'], close_fds=True, **kwargs)
|
||||||
if not background:
|
if not background:
|
||||||
return p.communicate(input)[0].rstrip('\n')
|
return p.communicate(input)[0].rstrip('\n')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user