diff --git a/bin/omarchy-update-stay-awake b/bin/omarchy-update-stay-awake index cd364c4e..11b391fe 100755 --- a/bin/omarchy-update-stay-awake +++ b/bin/omarchy-update-stay-awake @@ -468,8 +468,9 @@ start_locked() { trap cleanup_pending_launch EXIT atomic_write_state "$launch_control_file" "active $token" || return 1 - # The child is identifiable before it publishes state, including before exec. - # exec -a retains that identity without keeping an extra shell alive. + # The child is identifiable by the token in its arguments from the moment it + # starts. It stays a shell so stop's TERM ends it with a clean exit, since + # systemd-inhibit reports a child killed by a signal as an error. local hold_command=( /usr/bin/systemd-inhibit --what=sleep:idle --who=omarchy-update --why="Omarchy update in progress [$token]" --mode=block @@ -481,7 +482,6 @@ start_locked() { token=$2 owner=$3 control=$4 - expected="--why=Omarchy update in progress [$token]" temporary="" cleanup() { [[ -z $temporary ]] || /usr/bin/rm -f -- "$temporary"; } trap cleanup EXIT @@ -500,7 +500,9 @@ start_locked() { /usr/bin/flock -u "$control_fd" exec {control_fd}>&- trap - EXIT - exec -a "$expected" /usr/bin/sleep infinity + trap "kill \$!; exit 0" TERM + /usr/bin/sleep infinity & + wait ' "--why=Omarchy update in progress [$token]" "$state_dir" "$token" "$caller_uid" "$launch_control_file" ) diff --git a/test/shell.d/update-stay-awake-security-test.sh b/test/shell.d/update-stay-awake-security-test.sh index 6d473f30..2831a504 100644 --- a/test/shell.d/update-stay-awake-security-test.sh +++ b/test/shell.d/update-stay-awake-security-test.sh @@ -446,8 +446,8 @@ pause = ': >"$TEST_CANCEL_READY"; while :; do /usr/bin/sleep 0.02; done' if sys.argv[2] == 'published': anchor = ' while :; do\n inhibit_record=' edits = [(anchor, ' ' + pause + '\n' + anchor), - (' exec -a "$expected"', - ' while [[ ! -e $TEST_RELEASE_CHILD ]]; do /usr/bin/sleep 0.02; done\n exec -a "$expected"')] + (' trap "kill \\$!; exit 0" TERM', + ' while [[ ! -e $TEST_RELEASE_CHILD ]]; do /usr/bin/sleep 0.02; done\n trap "kill \\$!; exit 0" TERM')] elif sys.argv[2] == 'idle-temporary': anchor = ' temporary=$(mktemp "$state_dir/.${state_file##*/}.XXXXXXXX") || return 1' edits = [(anchor, anchor + '\n if [[ $state_file == "$idle_owner_file" ]]; then ' + pause + '; fi')]