aboutsummaryrefslogtreecommitdiff
path: root/internal/lock/lock.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-14 23:30:08 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-14 23:30:08 +0200
commit01b0cfe2055e23cf03870d9a9f60648037b4005e (patch)
treede9b82c31eec73b86f40e68c91489c3efd877da5 /internal/lock/lock.go
parent11a2c57c6eeaff0ef963fc6f8b74caa27b147bdb (diff)
downloadkrino-01b0cfe2055e23cf03870d9a9f60648037b4005e.tar.gz
krino-01b0cfe2055e23cf03870d9a9f60648037b4005e.zip
tests run on OpenBSD; a tool's error message survives one large write; lock pids beyond 32 bits name no process
Diffstat (limited to 'internal/lock/lock.go')
-rw-r--r--internal/lock/lock.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/internal/lock/lock.go b/internal/lock/lock.go
index 462b26e..2b98227 100644
--- a/internal/lock/lock.go
+++ b/internal/lock/lock.go
@@ -10,6 +10,7 @@ import (
"errors"
"fmt"
"io/fs"
+ "math"
"os"
"path/filepath"
"strconv"
@@ -156,8 +157,10 @@ func parsePid(s string) (int, bool) {
}
// running reports whether pid names a process that is currently running.
+// A pid outside the kernel's 32-bit range names no process: kill(2) would
+// cut it to its low bits and ask about another one.
func running(pid int) bool {
- if pid <= 0 {
+ if pid <= 0 || pid > math.MaxInt32 {
return false
}
proc, err := os.FindProcess(pid)