Add background mode support to localagent and implement instance check
This commit is contained in:
@@ -28,6 +28,19 @@ func Acquire() (*Guard, error) {
|
||||
return &Guard{handle: h}, nil
|
||||
}
|
||||
|
||||
func AlreadyRunning() bool {
|
||||
name, err := windows.UTF16PtrFromString(config.MutexName)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
h, err := windows.OpenMutex(windows.SYNCHRONIZE, false, name)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
windows.CloseHandle(h)
|
||||
return true
|
||||
}
|
||||
|
||||
func (g *Guard) Close() {
|
||||
if g == nil || g.handle == 0 {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user