Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

ugoArangino/SigSwift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SigSwift

This is a Swift wrapper for Darwin signal.h.

Usage

import Foundation
import SigSwift

public enum State {
    case started
    case stopped
}

var state: State = .started

SignalController.add(.INT) { (signalNumber) in
    guard let signal = Signal(rawValue: signalNumber) else {
        return
    }
    
    state = .stopped
    print("Intercepted signal: \(signal)")
    print("Set state to .stopped")
}

repeat {
    print("hello \(Date())")
    sleep(2)
} while (state == .started)

Build with: swift build
Run with ./.build/debug/Example

You can send the SIGINT signal with kill -2 thePID.

The application will return:

Intercepted signal: INT
Set state to .stopped

TODO

  • Documentation
  • Wrapp also Linux signal.h

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages