mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
Add RAII wrapper for signal_block/signal_unblock
This commit is contained in:
parent
f9118d964e
commit
bd122aa433
1 changed files with 13 additions and 0 deletions
13
src/signal.h
13
src/signal.h
|
@ -40,4 +40,17 @@ bool signal_is_blocked();
|
|||
|
||||
/// Returns signals with non-default handlers.
|
||||
void get_signals_with_handlers(sigset_t *set);
|
||||
|
||||
/// A RAII wrapper for signal_block/signal_unblock that triggers a signal block on creation, and then
|
||||
/// automatically releases the block when the object is destroyed, handling control flow and exceptions.
|
||||
struct signal_block_t {
|
||||
signal_block_t() {
|
||||
signal_block();
|
||||
}
|
||||
|
||||
~signal_block_t() {
|
||||
signal_unblock();
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue