📡 Process Signals
Observes process signals using Grand Central Dispatch DispatchSourceSignal.
This package is intended for use with Swift Package Manager. To use in your own package, add the following dependency:
dependencies: [ .package(url: "https://github.com/bluk/process-signals.git", from: "0.2.0") ]
A simple example application is given in the
You can run this application by cloning this repository and then running the following via Docker:
docker build . -t signals-example docker run -it --rm --name=signals signals-example
The process name and process identifier is output like:
Process: Example (1) Hello world!
You can send a signal to the process:
docker exec signals kill -s SIGUSR1 1
1 with the process identifier (should be
1 unless you change the
To stop the container, you can run:
docker stop signals
You can try modifying the
CMD to be various
To see what the behavior is (note the process identifier may change).
If you wish to modify this code, you can clone this repository and use Swift Package Manager to build and test this code.
swift build swift test
If you want to generate an Xcode project, you can run:
swift package generate-xcodeproj
To generate the documentation, you need Ruby installed, and then run:
bundle install swift package generate-xcodeproj jazzy -o docs --module "ProcessSignals" --module-version <version> -g https://github.com/bluk/process-signals
- signal(3) manual page
- Monitoring Signals
- Trapping signals in Docker containers
- Friday Q&A 2011-04-01: Signal Handling