github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/install/stop_windows.go (about) 1 // Copyright 2019 Keybase, Inc. All rights reserved. Use of 2 // this source code is governed by the included BSD license. 3 4 //go:build windows 5 // +build windows 6 7 package install 8 9 import ( 10 "fmt" 11 "os" 12 "path/filepath" 13 14 "github.com/keybase/client/go/libkb" 15 keybase1 "github.com/keybase/client/go/protocol/keybase1" 16 ) 17 18 // StopAllButService on windows can only stop those services which are not managed 19 // by the watchdog, because this is intended to be called before the service is shut down, 20 // and the watchdog dies when the service exists gracefully. 21 func StopAllButService(mctx libkb.MetaContext, exitCode keybase1.ExitCode) { 22 var err error 23 defer mctx.Trace(fmt.Sprintf("StopAllButService()"), 24 &err)() 25 mountdir, err := mctx.G().Env.GetMountDir() 26 if err != nil { 27 mctx.Error("StopAllButService: Error in GetCurrentMountDir: %s", err.Error()) 28 } else { 29 // open special "file". Errors not relevant. 30 exitFile := "\\.kbfs_unmount" 31 if exitCode == keybase1.ExitCode_RESTART { 32 exitFile = "\\.kbfs_restart" 33 } 34 unmountPath := filepath.Join(mountdir, exitFile) 35 mctx.Info("StopAllButService: opening %s", unmountPath) 36 _, err = os.Open(unmountPath) 37 if err != nil { 38 mctx.Debug("StopAllButService: unable to unmount kbfs (%s) but it might still have shut down successfully", err) 39 } 40 err = libkb.ChangeMountIcon(mountdir, "") 41 if err != nil { 42 mctx.Error("StopAllButService: unable to change mount icon: %s", err) 43 } 44 } 45 }