newSelfLockContent returns a lockContent describing the current process.
()
| 202 | |
| 203 | // newSelfLockContent returns a lockContent describing the current process. |
| 204 | func newSelfLockContent() (lockContent, error) { |
| 205 | pid := int32(os.Getpid()) // nolint: gosec |
| 206 | p, err := process.NewProcess(pid) |
| 207 | if err != nil { |
| 208 | return lockContent{}, fmt.Errorf("failed to look up own process: %w", err) |
| 209 | } |
| 210 | ct, err := p.CreateTime() |
| 211 | if err != nil { |
| 212 | return lockContent{}, fmt.Errorf("failed to get own start time: %w", err) |
| 213 | } |
| 214 | return lockContent{PID: pid, StartTime: ct}, nil |
| 215 | } |
| 216 | |
| 217 | // isLockFileStale reads the lock file and checks whether the owning process |
| 218 | // is dead or has a mismatched start time. Returns (true, content, nil) if |