From c8ddb121d0e23fd69d93b7f843c34289b19d6617 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Thu, 5 Dec 2019 21:07:56 +0100 Subject: [PATCH] simplify command execution --- owrx/source.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/owrx/source.py b/owrx/source.py index fb1127c..e08c98a 100644 --- a/owrx/source.py +++ b/owrx/source.py @@ -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