From 3888dca7e8ef22c40b8f3be72fff556a5133ee2d Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 11 Aug 2026 14:16:32 -0700 Subject: [PATCH] Stop script hanging up the inhibitor before it starts The sleep inhibitor deliberately outlives the start that spawns it, but script tears its pty down as soon as the command returns, and the SIGHUP that follows could kill the inhibitor before it managed to exec. The sudo stub then never logged and the test failed about half the time. Hold the session open from inside until the inhibitor has started. Co-Authored-By: Claude Opus 5 --- test/shell.d/update-lock-test.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/shell.d/update-lock-test.sh b/test/shell.d/update-lock-test.sh index 9ec57840..ed195fc9 100644 --- a/test/shell.d/update-lock-test.sh +++ b/test/shell.d/update-lock-test.sh @@ -128,8 +128,22 @@ fi exec "$@"' write_stub pkexec 'touch "$PKEXEC_MARKER"; exec "$@"' + # start leaves the inhibitor running on purpose, but script tears the pty down + # the moment its command returns, which SIGHUPs that inhibitor before it can + # exec. Keep the session open from the inside until the stub has logged. + terminal_driver="$test_tmp/terminal-stay-awake" + cat >"$terminal_driver" <<'SH' +#!/bin/bash +omarchy-update-stay-awake start +for _ in {1..200}; do + grep -q '^systemd-inhibit ' "$SUDO_LOG" && break + sleep 0.05 +done +SH + chmod +x "$terminal_driver" + SUDO_LOG="$sudo_log" PKEXEC_MARKER="$pkexec_marker" INHIBIT_PID_FILE="$terminal_inhibit_pid_file" \ - run_with_lock_env script -qefc "$ROOT/bin/omarchy-update-stay-awake start" /dev/null >/dev/null + run_with_lock_env script -qefc "$terminal_driver" /dev/null >/dev/null grep -qx -- '-v' "$sudo_log" || fail "terminal sleep inhibition validates sudo in the foreground" grep -q '^systemd-inhibit ' "$sudo_log" || fail "terminal sleep inhibition runs through sudo"