simplify command execution

This commit is contained in:
Jakob Ketterl 2019-12-05 21:07:56 +01:00
parent ba5613cf62
commit c8ddb121d0
1 changed files with 8 additions and 1 deletions

View File

@ -14,6 +14,7 @@ import signal
import sys
import socket
import logging
import shlex
logger = logging.getLogger(__name__)
@ -241,7 +242,13 @@ class SdrSource(object):
self.port,
)
self.process = subprocess.Popen(cmd, shell=True, preexec_fn=os.setpgrp)
# don't use shell mode for commands without piping
if "|" in cmd:
self.process = subprocess.Popen(cmd, shell=True, preexec_fn=os.setpgrp)
else:
# preexec_fn can go as soon as there's no piped commands left
# the os.killpg call must be replaced with something more reasonable at the same time
self.process = subprocess.Popen(shlex.split(cmd), preexec_fn=os.setpgrp)
logger.info("Started rtl source: " + cmd)
available = False