github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/install/terminate_nonmobile.go (about)

     1  //go:build !ios && !android
     2  // +build !ios,!android
     3  
     4  package install
     5  
     6  import (
     7  	"time"
     8  
     9  	"github.com/keybase/client/go/logger"
    10  	"github.com/keybase/client/go/updater/process"
    11  )
    12  
    13  // TerminateApp will stop the Keybase (UI) app
    14  func TerminateApp(context Context, log Log) error {
    15  	appExecName := "Keybase"
    16  	logf := logger.NewLoggerf(log)
    17  	log.Info("Stopping Keybase app")
    18  	appPIDs := process.TerminateAll(process.NewMatcher(appExecName, process.ExecutableEqual, logf), 5*time.Second, logf)
    19  	if len(appPIDs) > 0 {
    20  		log.Info("Terminated %s %v", appExecName, appPIDs)
    21  	} else {
    22  		log.Debug("Did not terminate anything")
    23  	}
    24  	return nil
    25  }