1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00
putty-source/unix/utils/block_signal.c
Simon Tatham d509a2dc1e Formatting: normalise to put a space after condition keywords.
'if (thing)' is the local style here, not 'if(thing)'. Similarly with
'for' and 'while'.
2022-12-28 15:32:24 +00:00

22 lines
411 B
C

/*
* Handy function to block or unblock a signal, which does all the
* messing about with sigset_t for you.
*/
#include <signal.h>
#include <stdlib.h>
#include "defs.h"
void block_signal(int sig, bool block_it)
{
sigset_t ss;
sigemptyset(&ss);
sigaddset(&ss, sig);
if (sigprocmask(block_it ? SIG_BLOCK : SIG_UNBLOCK, &ss, 0) < 0) {
perror("sigprocmask");
exit(1);
}
}