MCPcopy Index your code
hub / github.com/cloudflare/cloudflared / newSelfLockContent

Function newSelfLockContent

token/token.go:204–215  ·  view source on GitHub ↗

newSelfLockContent returns a lockContent describing the current process.

()

Source from the content-addressed store, hash-verified

202
203// newSelfLockContent returns a lockContent describing the current process.
204func 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

Callers 3

TestNewSelfLockContentFunction · 0.85
tryCreateLockFileFunction · 0.85

Calls 1

ErrorfMethod · 0.80

Tested by 2

TestNewSelfLockContentFunction · 0.68