mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-22 12:15:32 +08:00
Add RAII wrapper for signal_block/signal_unblock
This commit is contained in:
parent
f9118d964e
commit
bd122aa433
13
src/signal.h
13
src/signal.h
|
@ -40,4 +40,17 @@ bool signal_is_blocked();
|
||||||
|
|
||||||
/// Returns signals with non-default handlers.
|
/// Returns signals with non-default handlers.
|
||||||
void get_signals_with_handlers(sigset_t *set);
|
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
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user