Skip to content

fix(upgrade): handle EPERM in isProcessRunning for cross-user locks#211

Merged
BYK merged 2 commits intomainfrom
fix/is-process-running-eperm
Feb 6, 2026
Merged

fix(upgrade): handle EPERM in isProcessRunning for cross-user locks#211
BYK merged 2 commits intomainfrom
fix/is-process-running-eperm

Conversation

@BYK
Copy link
Member

@BYK BYK commented Feb 6, 2026

Summary

Fixes a bug in isProcessRunning where processes owned by a different user were incorrectly identified as not running.

On Unix, process.kill(pid, 0) throws:

  • ESRCH: Process does not exist (not running)
  • EPERM: Process exists but we lack permission to signal it (IS running)

The previous code caught all errors and returned false, which would cause handleExistingLock to incorrectly treat an active lock held by another user's process as stale.

Changes

  • Check for EPERM error code and return true (process is running)
  • Only return false for ESRCH and other errors

Testing

  • Existing tests pass
  • This edge case is difficult to test without root privileges, but the fix follows the well-established Unix pattern for process existence checks

On Unix, process.kill(pid, 0) throws EPERM when the process exists but
is owned by a different user. The previous code treated all errors as
'process not running', which would incorrectly identify an active lock
held by another user's process as stale.

Now EPERM is handled correctly - if we get EPERM, the process IS running,
we just can't signal it.
@github-actions
Copy link

github-actions bot commented Feb 6, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (cli) Add plural command aliases for list commands by betegon in #209

Bug Fixes 🐛

Upgrade

  • Handle EPERM in isProcessRunning for cross-user locks by BYK in #211
  • Replace curl pipe with direct binary download by BYK in #208

Documentation 📚

  • Add documentation for log command by betegon in #210

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link

github-actions bot commented Feb 6, 2026

Codecov Results 📊

✅ Patch coverage is 100.00%. Project has 1959 uncovered lines.
✅ Project coverage is 76.73%. Comparing base (base) to head (head).

Files with missing lines (40)
File Patch % Lines
human.ts 55.31% ⚠️ 391 Missing
resolve-target.ts 15.28% ⚠️ 366 Missing
oauth.ts 25.10% ⚠️ 194 Missing
api-client.ts 70.62% ⚠️ 176 Missing
upgrade.ts 67.31% ⚠️ 102 Missing
view.ts 47.70% ⚠️ 91 Missing
migration.ts 47.44% ⚠️ 82 Missing
browser.ts 4.11% ⚠️ 70 Missing
span-tree.ts 5.00% ⚠️ 57 Missing
telemetry.ts 77.51% ⚠️ 56 Missing
api.ts 89.80% ⚠️ 47 Missing
seer.ts 75.54% ⚠️ 45 Missing
schema.ts 89.56% ⚠️ 40 Missing
seer.ts 79.87% ⚠️ 30 Missing
preload.ts 53.23% ⚠️ 29 Missing
utils.ts 88.94% ⚠️ 25 Missing
detector.ts 90.10% ⚠️ 20 Missing
output.ts 15.00% ⚠️ 17 Missing
code-scanner.ts 95.00% ⚠️ 16 Missing
arg-parsing.ts 90.00% ⚠️ 12 Missing
dsn-cache.ts 94.62% ⚠️ 12 Missing
fix.ts 83.61% ⚠️ 10 Missing
qrcode.ts 33.33% ⚠️ 10 Missing
fs-utils.ts 57.14% ⚠️ 9 Missing
project-root.ts 97.73% ⚠️ 7 Missing
version-check.ts 91.76% ⚠️ 7 Missing
feedback.ts 84.21% ⚠️ 6 Missing
auth.ts 95.52% ⚠️ 6 Missing
upgrade.ts 93.83% ⚠️ 5 Missing
resolver.ts 94.57% ⚠️ 5 Missing
index.ts 95.96% ⚠️ 4 Missing
project-aliases.ts 97.40% ⚠️ 2 Missing
project-root-cache.ts 96.92% ⚠️ 2 Missing
json.ts 33.33% ⚠️ 2 Missing
alias.ts 99.42% ⚠️ 1 Missing
env-file.ts 99.19% ⚠️ 1 Missing
parser.ts 98.63% ⚠️ 1 Missing
colors.ts 97.96% ⚠️ 1 Missing
helpers.ts 94.74% ⚠️ 1 Missing
helpers.ts 94.74% ⚠️ 1 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    76.72%    76.73%    +0.01%
==========================================
  Files           65        65         —
  Lines         8416      8419        +3
  Branches         0         0         —
==========================================
+ Hits          6457      6460        +3
- Misses        1959      1959         —
- Partials         0         0         —

Generated by Codecov Action

…ning

Adds two tests to cover the EPERM handling fix:
- EPERM: returns true (process exists but owned by different user)
- ESRCH: returns false (process does not exist)

This should improve patch coverage above 80%.
@BYK BYK merged commit fe8631b into main Feb 6, 2026
24 checks passed
@BYK BYK deleted the fix/is-process-running-eperm branch February 6, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant