alexito4 / Trap

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

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

License:MIT License


Languages

Language:Swift 89.9%Language:Objective-C 10.1%