14360: Use nonblocking mode when checking for stale lock.
[arvados.git] / services / crunch-run / background.go
index ee054f056fac8e69a66ae4e4f10a5f6082cac834..deaf09cec84a7cd3e3549a9223ff4a913ebc053c 100644 (file)
@@ -160,7 +160,7 @@ func ListProcesses(stdout, stderr io.Writer) int {
                // acquisition during races, e.g., by connecting to a
                // unix socket or checking /proc/$pid/fd/$n ->
                // lockfile.
-               err = syscall.Flock(int(f.Fd()), syscall.LOCK_SH)
+               err = syscall.Flock(int(f.Fd()), syscall.LOCK_SH|syscall.LOCK_NB)
                if err == nil {
                        // lockfile is stale
                        err := os.Remove(path)