I have a process that I start and keep alive like this.
ServerMain.shared.startFSM()
CFRunLoopRun()
Now I’m trying to react accordingly to when the computer is going to sleep, or shutting down so I’m trying to catch the SIGTERM signal as follows.
private func setSIGTERMSignalHandler() {
let signalSource = DispatchSource.makeSignalSource(signal: SIGTERM, queue: .main)
signalSource.setEventHandler {
self.signOut()
}
signalSource.resume()
signTermSource = signalSource
}
However the event handler is not getting called in any circumstance. Is this the right track to catch them since it is a LaunchDaemon?