From 65270eaea83d48a240579cb6f5eb6a1c4684a9c9 Mon Sep 17 00:00:00 2001 From: Stacy Harper Date: Thu, 8 Apr 2021 13:57:34 +0200 Subject: [PATCH] Prevent starting multiple modemmonitor on logout/login Signed-off-by: Stacy Harper Signed-off-by: Maarten van Gompel --- scripts/modem/sxmo_modemmonitortoggle.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/modem/sxmo_modemmonitortoggle.sh b/scripts/modem/sxmo_modemmonitortoggle.sh index 7c76055..7dc49ee 100755 --- a/scripts/modem/sxmo_modemmonitortoggle.sh +++ b/scripts/modem/sxmo_modemmonitortoggle.sh @@ -9,8 +9,8 @@ . "$(dirname "$0")/sxmo_common.sh" if [ "$1" != "on" ] && pgrep -f sxmo_modemmonitor.sh; then - pgrep -f sxmo_modemmonitor.sh | grep -Ev "^${$}$" | xargs -IP kill -TERM P -elif [ "$1" != "off" ]; then + pkill -TERM -f sxmo_modemmonitor.sh +elif [ "$1" != "off" ] && ! pgrep -f sxmo_modemmonitor.sh; then setsid -f sxmo_modemmonitor.sh & fi