Add background mode support to localagent and implement instance check

This commit is contained in:
2026-08-18 17:03:20 +03:00
parent fe77f17ac9
commit 15f7fd91ab
3 changed files with 78 additions and 2 deletions
+13
View File
@@ -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