From 2b5f2b97e7896ed24f766c4464fbbacb51471c62 Mon Sep 17 00:00:00 2001 From: Maarten van Gompel Date: Sun, 25 Jul 2021 14:19:37 +0200 Subject: [PATCH] if multiple sxmo_rtcwake processes are running, return to crust only when the last one exits Signed-off-by: Stacy Harper --- scripts/core/sxmo_rtcwake.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/core/sxmo_rtcwake.sh b/scripts/core/sxmo_rtcwake.sh index 0911032..aaedd80 100644 --- a/scripts/core/sxmo_rtcwake.sh +++ b/scripts/core/sxmo_rtcwake.sh @@ -14,8 +14,14 @@ finish() { if grep -q crust "$LASTSTATE" \ && grep -q rtc "$UNSUSPENDREASONFILE" \ && [ "$(sxmo_screenlock.sh getCurState)" != "unlock" ]; then - echo "sxmo_rtcwake: going back to crust ($(date))" >&2 - sxmo_screenlock.sh crust + WAKEPROCS=$(pgrep -f sxmo_rtcwake.sh | wc -l) + if [ "$WAKEPROCS" -gt 2 ]; then + #each process also spawns a blink subprocess, so we check if there are more than two rather than one: + echo "sxmo_rtcwake: returning without crust, other sxmo_rtcwake process is still running ($(date))" >&2 + else + echo "sxmo_rtcwake: going back to crust ($(date))" >&2 + sxmo_screenlock.sh crust + fi else echo "sxmo_rtcwake: returning without crust ($(date))" >&2 fi