mirror of
https://github.com/safing/portmaster
synced 2025-09-01 18:19:12 +00:00
- Fix service creation - Singleton lock - Control error/logging - Revamp run/service interaction - Add option to turn off stdout/stderr output (for Windows Service) - Use log instead of fmt.Print*
31 lines
787 B
Go
31 lines
787 B
Go
package main
|
|
|
|
import (
|
|
"sync"
|
|
)
|
|
|
|
var (
|
|
startupComplete = make(chan struct{}) // signal that the start procedure completed (is never closed, just signaled once)
|
|
shuttingDown = make(chan struct{}) // signal that we are shutting down (will be closed, may not be closed directly, use initiateShutdown)
|
|
shutdownInitiated = false // not to be used directly
|
|
shutdownError error // may not be read or written to directly
|
|
shutdownLock sync.Mutex
|
|
)
|
|
|
|
func initiateShutdown(err error) {
|
|
shutdownLock.Lock()
|
|
defer shutdownLock.Unlock()
|
|
|
|
if !shutdownInitiated {
|
|
shutdownInitiated = true
|
|
shutdownError = err
|
|
close(shuttingDown)
|
|
}
|
|
}
|
|
|
|
func getShutdownError() error {
|
|
shutdownLock.Lock()
|
|
defer shutdownLock.Unlock()
|
|
|
|
return shutdownError
|
|
}
|