mirror of
https://github.com/restic/restic.git
synced 2026-06-21 16:14:18 +00:00
c87da70af9
Reduce Lock to a pure data transfer object and move the logic to lockHandle.
23 lines
486 B
Go
23 lines
486 B
Go
package repository
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/restic/restic/internal/debug"
|
|
)
|
|
|
|
// checkProcess will check if the process retaining the lock exists.
|
|
// Returns true if the process exists.
|
|
func (l *lockHandle) processExists() bool {
|
|
proc, err := os.FindProcess(l.PID)
|
|
if err != nil {
|
|
debug.Log("error searching for process %d: %v\n", l.PID, err)
|
|
return false
|
|
}
|
|
err = proc.Release()
|
|
if err != nil {
|
|
debug.Log("error releasing process %d: %v\n", l.PID, err)
|
|
}
|
|
return true
|
|
}
|