fix(lock): prefer $EPOCHSECONDS over date +%s for stale lock time check#56
Open
kitsuyui wants to merge 1 commit into
Open
fix(lock): prefer $EPOCHSECONDS over date +%s for stale lock time check#56kitsuyui wants to merge 1 commit into
kitsuyui wants to merge 1 commit into
Conversation
On platforms where date +%s is unavailable (restricted environments,
minimal Docker images, some self-hosted runners), the time-based stale
lock detection silently degraded to a no-op, leaving only the PID
liveness check active.
Replace `now=$(date +%s 2>/dev/null) || now=0` with
now=${EPOCHSECONDS:-$(date +%s 2>/dev/null || echo 0)}.
$EPOCHSECONDS is a bash 5.0+ built-in that gives the current Unix epoch
without spawning an external process. GitHub-hosted runners (ubuntu,
macos, windows) all provide bash 5.x. On bash < 5 the variable is unset
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On platforms where
date +%sis unavailable (restricted environments,minimal Docker images, some self-hosted runners), the time-based stale
lock detection in
acquire_boilerplates_lock()silently degraded to ano-op, leaving only the PID liveness check active.
This PR replaces:
with:
now=${EPOCHSECONDS:-$(date +%s 2>/dev/null || echo 0)}$EPOCHSECONDSis a bash 5.0+ built-in variable that exposes the currentUnix epoch without spawning an external process. GitHub-hosted runners
(ubuntu, macos, windows) all provide bash 5.x through
shell: bash.On bash < 5 the variable is unset and the fallback to
date +%sapplies,preserving existing behaviour.
Impact
date +%sunavailable: time-based stale detection now worksdate +%sunavailable: unchanged (time-based check remains disabled)Related
PR #54 addresses visibility of
pid_tswrite failure on the acquisition side.That PR and this one are independent — the write-side timestamp format is unchanged.
Test plan