Skip to content
/ Trap Public

It’s a trap! Catch OS signals in Swift. Swift Signal Handler.

License

Notifications You must be signed in to change notification settings

alexito4/Trap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trap

Giphy

Trap is a small Swift framework to handle operating system signals.

Usage

import Trap

let task = NSTask...

Trap.handle(.interrupt) {
    task.terminate()
    exit(EXIT_FAILURE)
}

task.launch()

It can also handle multiple signals at the same time.

Trap.handle(Trap.Signal.all) {
    print("Signal: \($0)")
    ...
}

Requirements

Trap is build using the stable version of Swift 3.0.