summaryrefslogtreecommitdiff
path: root/internal/stats/lock_posix.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-13 08:09:33 +0300
committerPaul Buetow <paul@buetow.org>2026-04-13 08:10:16 +0300
commitf2dd8d8a515c1a2a220836231ad1a671a5e9b73d (patch)
tree5b19585afb01b60d03d24a96b57bc7b986ea4cc0 /internal/stats/lock_posix.go
parent56002ff942de1bfb0ce467ec37a692b8c4ca01e9 (diff)
ask: serialize concurrent CLI with repo lock and stale PID recovery
Add advisory lock under .git/hexai-ask.lock around Taskwarrior execution, with metadata (PID and process basename) and Linux /proc comm checks to remove orphan lock files when the recorded holder is gone or not ask. Extract internal/filelock for shared flock helpers; stats uses it too. Made-with: Cursor
Diffstat (limited to 'internal/stats/lock_posix.go')
-rw-r--r--internal/stats/lock_posix.go23
1 files changed, 0 insertions, 23 deletions
diff --git a/internal/stats/lock_posix.go b/internal/stats/lock_posix.go
deleted file mode 100644
index 2c41d31..0000000
--- a/internal/stats/lock_posix.go
+++ /dev/null
@@ -1,23 +0,0 @@
-//go:build !windows
-
-package stats
-
-import (
- "errors"
-
- "golang.org/x/sys/unix"
-)
-
-func tryLockFile(fd uintptr) error {
- if err := unix.Flock(int(fd), unix.LOCK_EX|unix.LOCK_NB); err != nil {
- if errors.Is(err, unix.EWOULDBLOCK) {
- return errLockWouldBlock
- }
- return err
- }
- return nil
-}
-
-func unlockFile(fd uintptr) error {
- return unix.Flock(int(fd), unix.LOCK_UN)
-}