Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.
/ Trap Public archive

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.