Last active
August 31, 2022 18:28
-
-
Save mdales/68e2345f7be3d71377a29904d07643f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Dispatch | |
import Foundation | |
let syncQ = DispatchQueue(label: "sync") | |
var count = 0 | |
let q = DispatchQueue(label: "test") | |
func test() { | |
syncQ.sync { | |
print("hello \(count)") | |
} | |
q.asyncAfter(deadline: .now() + 1.0, execute: test) | |
} | |
q.asyncAfter(deadline: .now() + 1.0, execute: test) | |
public func registerSighup() -> DispatchSourceSignal { | |
signal(SIGHUP, SIG_IGN) | |
let sigintSrc = DispatchSource.makeSignalSource(signal: SIGHUP, queue: syncQ) | |
sigintSrc.setEventHandler { | |
count += 1 | |
} | |
sigintSrc.resume() | |
return sigintSrc | |
} | |
let source = registerSighup() | |
dispatchMain() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment