From a3e1ad0a00ba836e7a9a7ae31a07aee033c46ca1 Mon Sep 17 00:00:00 2001 From: Solomag <33348398+Solomag@users.noreply.github.com> Date: Fri, 20 Nov 2026 10:46:30 +0100 Subject: [PATCH 1/2] service.sh: ignore a stale scheduler pid from a previous boot The single-instance guard used a bare kill -0 on the pid stored in scheduler.loop.pid. That file survives a reboot and Android reuses pids quickly, so the stored pid can belong to an unrelated live process. The guard then exits before the scheduler loop and the VDLU boot update. Record the boot_id next to the pid and only trust the pid when it was written during the current boot. Signed-off-by: Solomag <33348398+Solomag@users.noreply.github.com> --- module/service.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/module/service.sh b/module/service.sh index 3cbdf1f..3001713 100644 --- a/module/service.sh +++ b/module/service.sh @@ -25,6 +25,8 @@ d="${0%/*}"; [ "$d" = "$0" ] && d="."; MODDIR="$(cd "$d" 2>/dev/null && pwd || e STATE_DIR=/data/adb/vdbackup LOGS="$STATE_DIR/logs" LOOPPID="$LOGS/scheduler.loop.pid" +LOOPBOOT="$LOGS/scheduler.loop.boot" +BOOTID="$(cat /proc/sys/kernel/random/boot_id 2>/dev/null)" INTERVAL=900 # wait for boot to complete before touching the framework @@ -48,11 +50,15 @@ mkdir -p "$LOGS" # honour the skip flag [ -f "$MODDIR/.scheduler.skip" ] && exit 0 -# single-instance guard: bail out if a scheduler loop is already alive -if [ -f "$LOOPPID" ] && kill -0 "$(cat "$LOOPPID" 2>/dev/null)" 2>/dev/null; then exit 0; fi +# single-instance guard: bail out if a scheduler loop is already alive. The pid file survives a +# reboot and Android reuses pids quickly, so a bare kill -0 can match an unrelated process and make +# this script exit before the scheduler and the VDLU boot update; only trust a pid recorded in the +# current boot (boot_id). +if [ -f "$LOOPPID" ] && [ "$(cat "$LOOPBOOT" 2>/dev/null)" = "$BOOTID" ] && kill -0 "$(cat "$LOOPPID" 2>/dev/null)" 2>/dev/null; then exit 0; fi # recurring, detached heartbeat (survives boot, never blocks it): the loop # records its own pid for the guard, then runs scheduler-tick every INTERVAL. +echo "$BOOTID" > "$LOOPBOOT" setsid nohup sh -c ' echo "$$" > "$1" while :; do From 8989b63ee85249c9a128f46177ea01b5a0045f46 Mon Sep 17 00:00:00 2001 From: Solomag <33348398+Solomag@users.noreply.github.com> Date: Fri, 20 Nov 2026 10:48:03 +0100 Subject: [PATCH 2/2] uninstall.sh: only kill the scheduler pid recorded in the current boot Same stale-pid exposure as service.sh: after a reboot the pid file can point at an unrelated live process. Compare scheduler.loop.boot with the current boot_id before signalling, and clean the marker on uninstall. Signed-off-by: Solomag <33348398+Solomag@users.noreply.github.com> --- module/uninstall.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/module/uninstall.sh b/module/uninstall.sh index 0f74437..bc6f808 100644 --- a/module/uninstall.sh +++ b/module/uninstall.sh @@ -30,7 +30,11 @@ STATE_DIR=/data/adb/vdbackup # stop the detached scheduler heartbeat first, so it does not keep spinning every 900s # against a helper.sh that uninstall is about to remove (harmless but noisy until reboot). _lp="$(cat "$STATE_DIR/logs/scheduler.loop.pid" 2>/dev/null)" -case "$_lp" in ''|*[!0-9]*) : ;; *) kill "$_lp" 2>/dev/null ;; esac +# only signal the pid when it was recorded in this boot (scheduler.loop.boot == boot_id): the pid file +# survives a reboot and Android reuses pids, so a stale pid could belong to an unrelated process. +_lb="$(cat "$STATE_DIR/logs/scheduler.loop.boot" 2>/dev/null)" +_bid="$(cat /proc/sys/kernel/random/boot_id 2>/dev/null)" +case "$_lp" in ''|*[!0-9]*) : ;; *) [ "$_lb" = "$_bid" ] && kill "$_lp" 2>/dev/null ;; esac rm -rf "$STATE_DIR/staging" "$STATE_DIR/iconcache" 2>/dev/null -rm -f "$STATE_DIR/logs"/*.pid "$STATE_DIR/logs"/*.out "$STATE_DIR/logs"/progress-*.json 2>/dev/null +rm -f "$STATE_DIR/logs"/*.pid "$STATE_DIR/logs"/scheduler.loop.boot "$STATE_DIR/logs"/*.out "$STATE_DIR/logs"/progress-*.json 2>/dev/null exit 0