0
func updatePM() {
    signal(SIGINT, SIG_IGN)

    let sigintSrc = DispatchSource.makeSignalSource(signal: SIGINT, queue: nil)
    sigintSrc.setEventHandler {
        // I wanna stop this func()
    }
    sigintSrc.resume()
    
    // do something(I can't controll it, it's a api)
}

How can I do to stop this func. 'do somthing' just like execute some command in ssh, is a third party api(Shout)

  • Check out [DispatchWorkItem](https://stackoverflow.com/questions/44633729/stop-a-dispatchqueue-that-is-running-on-the-main-thread/44634230#44634230)s. – Dávid Pásztor Aug 13 '21 at 09:49

0 Answers0