diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 23:30:08 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 23:30:08 +0200 |
| commit | 01b0cfe2055e23cf03870d9a9f60648037b4005e (patch) | |
| tree | de9b82c31eec73b86f40e68c91489c3efd877da5 /internal/lock/lock_test.go | |
| parent | 11a2c57c6eeaff0ef963fc6f8b74caa27b147bdb (diff) | |
| download | krino-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_test.go')
| -rw-r--r-- | internal/lock/lock_test.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/internal/lock/lock_test.go b/internal/lock/lock_test.go index fca4d76..53ce5ca 100644 --- a/internal/lock/lock_test.go +++ b/internal/lock/lock_test.go @@ -122,3 +122,16 @@ func TestStaleLockIsTakenOver(t *testing.T) { t.Error("the takeover was not reported to the caller") } } + +// TestRunningRejectsPidsBeyondTheKernelsRange: a pid wider than 32 bits in a +// damaged lock file is cut to its low bits by kill(2), so without a range +// check it names some other process - here this very one - and a stale lock +// would never be taken over. +func TestRunningRejectsPidsBeyondTheKernelsRange(t *testing.T) { + if running(os.Getpid() + 1<<32) { + t.Error("running(pid + 2^32) is true: the pid was truncated to this process") + } + if !running(os.Getpid()) { + t.Error("running(own pid) is false") + } +} |
