github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/updater/service/service_nix.go (about)

     1  //go:build !windows
     2  // +build !windows
     3  
     4  package main
     5  
     6  import (
     7  	"io"
     8  	"path/filepath"
     9  
    10  	"github.com/keybase/client/go/updater/keybase"
    11  )
    12  
    13  func (s *service) lockPID() (io.Closer, error) {
    14  	cacheDir, err := keybase.CacheDir(s.appName)
    15  	if err != nil {
    16  		return nil, err
    17  	}
    18  	lockPID := NewLockPIDFile(filepath.Join(cacheDir, "updater.pid"), s.log)
    19  	if err := lockPID.Lock(); err != nil {
    20  		return nil, err
    21  	}
    22  	s.log.Debug("update pid file %s created, updater service starting", lockPID.name)
    23  	return lockPID, nil
    24  }