Files
beads/internal/lockfile/process_unix.go
beads/crew/emma 21de43538d fix: eliminate 5+ second delays from stale daemon.lock files (bd-htwx)
Root cause: When a bd daemon crashes, its daemon.lock file remains with
the old PID. If that PID gets reused by an unrelated process, the code
would wait 5 seconds for a socket that will never appear.

Fix: Use flock-based check as authoritative source for daemon liveness.
The OS releases flocks when a process dies, so this is immune to PID reuse.

Changes:
- handleExistingSocket: Check daemon flock before waiting for socket
- acquireStartLock: Verify daemon lock is held before waiting
- handleStaleLock: Use flock check to detect stale startlocks
- lockfile/process_*.go: Add pid <= 0 check to prevent false positives
  (PID 0 signals process group on Unix, not a specific process)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-31 13:03:49 -08:00

16 lines
330 B
Go

//go:build unix || linux || darwin
package lockfile
import (
"syscall"
)
// isProcessRunning checks if a process with the given PID is running
func isProcessRunning(pid int) bool {
if pid <= 0 {
return false // Invalid PID (0 would signal our process group, not a specific process)
}
return syscall.Kill(pid, 0) == nil
}