MCPcopy
hub / github.com/wavetermdev/waveterm / AcquireWaveLock

Function AcquireWaveLock

pkg/wavebase/wavebase-posix.go:16–30  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14)
15
16func AcquireWaveLock() (FDLock, error) {
17 dataHomeDir := GetWaveDataDir()
18 lockFileName := filepath.Join(dataHomeDir, WaveLockFile)
19 log.Printf("[base] acquiring lock on %s\n", lockFileName)
20 fd, err := os.OpenFile(lockFileName, os.O_RDWR|os.O_CREATE, 0600)
21 if err != nil {
22 return nil, err
23 }
24 err = unix.Flock(int(fd.Fd()), unix.LOCK_EX|unix.LOCK_NB)
25 if err != nil {
26 fd.Close()
27 return nil, err
28 }
29 return fd, nil
30}

Callers 1

mainFunction · 0.92

Calls 3

GetWaveDataDirFunction · 0.85
FdMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected