Skip to content

fix: make lock acquisition signal-safe - #7

Merged
BartoszBlizniak merged 2 commits into
mainfrom
agent/make-lock-acquisition-signal-safe
Jul 17, 2026
Merged

fix: make lock acquisition signal-safe#7
BartoszBlizniak merged 2 commits into
mainfrom
agent/make-lock-acquisition-signal-safe

Conversation

@BartoszBlizniak

Copy link
Copy Markdown
Member

What changed

  • make lock acquisition and ownership recording indivisible to INT/TERM cleanup
  • restore the installer signal handlers immediately after each acquisition attempt
  • add a deterministic regression test that signals the installer immediately after mkdir creates the lock

Why

A signal arriving after mkdir succeeded but before LOCK_DIR was assigned could leave a permanent stale lock. Later installations would wait for 120 seconds and fail until the directory was removed manually.

Impact

Interrupted acquisition can no longer strand the installation lock, while waiting installers still cannot remove a lock owned by another process.

Validation

  • shellcheck --shell=sh --severity=style install.sh
  • bats tests/ (43 tests passed)
  • git diff --check

Copilot AI review requested due to automatic review settings July 17, 2026 08:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

  • Purpose: harden install.sh lock acquisition against INT/TERM arriving between successful mkdir of the lock directory and recording ownership for cleanup, and add a regression test to prevent stale lock regressions.

Changes:

  • Add enable_signal_traps() helper and use it from main() to centralize INT/TERM handling.
  • Make lock acquisition + LOCK_DIR assignment effectively indivisible with temporary signal handling changes around mkdir.
  • Add a deterministic Bats regression test that injects a TERM immediately after the lock directory is created.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
install.sh Adjusts signal handling during lock acquisition so cleanup can’t strand a lock directory.
tests/install.bats Adds a regression test that simulates a signal arriving immediately after lock creation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread install.sh Outdated
Comment thread install.sh
Comment thread tests/install.bats
@BartoszBlizniak
BartoszBlizniak merged commit b4285cd into main Jul 17, 2026
11 checks passed
@BartoszBlizniak
BartoszBlizniak deleted the agent/make-lock-acquisition-signal-safe branch July 17, 2026 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants