Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kurotych/unixsignallistener
Single-header C++ wrapper for safe processing UNIX signals
https://github.com/kurotych/unixsignallistener
handler signal single-header-lib unix unix-signals
Last synced: about 1 month ago
JSON representation
Single-header C++ wrapper for safe processing UNIX signals
- Host: GitHub
- URL: https://github.com/kurotych/unixsignallistener
- Owner: kurotych
- Created: 2020-05-06T19:41:49.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-06T20:44:01.000Z (almost 5 years ago)
- Last Synced: 2024-11-08T10:52:04.512Z (3 months ago)
- Topics: handler, signal, single-header-lib, unix, unix-signals
- Language: C++
- Homepage:
- Size: 6.84 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# C++ wrapper for processing UNIX signals.
It is developed according to the common approach for multi-threaded programs.## Interface:
##### *Block all UNIX signals. Should be called before creating any threads.*
```void init()```---
##### *Set function for handling UNIX signal.*
```void setHandler(int signum, std::function handler, bool terminate = false)```---
##### *Listen the unix signals. Blocks current thread. It can be unblocked if handler with flag terminate=true was triggered.*
```void listen()```
---
##### *Set signal that terminates listening (without handler)*
```void setTerminateSignal(int signum)```---
##### Set ignoring of a signal. Equals to: signal(signum, SIG_IGN);
```void setSigIgnore(int signum)```---
##### Set timeout handler. The handler will be called by timeout if no signals are received.
```void setTimeoutHandler(uint timeout, std::function handler)```---
Build and Run example:
```
g++ example.cpp -o unix_example -pthread
./unix_example
pkill unix_example (from other terminal)
```