aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphael Robatsch <raphael-git@tapesoftware.net>2022-12-03 19:12:30 +0100
committerRaphael Robatsch <raphael-git@tapesoftware.net>2022-12-03 19:12:30 +0100
commit221daf2f5d9543db0821533deced34e23c80f53e (patch)
tree7e00dc6f2b587cda95cf7a089223987aba70a554
parente7214b60fa65dd375a8c72b146171cfa2236e983 (diff)
use sigaction(2) instead of signal(2)
To prevent crashes
-rw-r--r--someblocks.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/someblocks.c b/someblocks.c
index 8103164..f149896 100644
--- a/someblocks.c
+++ b/someblocks.c
@@ -95,15 +95,18 @@ void getsigcmds(unsigned int signal)
void setupsignals()
{
+ struct sigaction sa = {0};
#ifndef __OpenBSD__
- /* initialize all real time signals with dummy handler */
- for (int i = SIGRTMIN; i <= SIGRTMAX; i++)
- signal(i, dummysighandler);
+ /* initialize all real time signals with dummy handler */
+ sa.sa_handler = dummysighandler;
+ for (int i = SIGRTMIN; i <= SIGRTMAX; i++)
+ sigaction(i, &sa, NULL);
#endif
+ sa.sa_handler = sighandler;
for (unsigned int i = 0; i < LENGTH(blocks); i++) {
if (blocks[i].signal > 0)
- signal(SIGMINUS+blocks[i].signal, sighandler);
+ sigaction(SIGMINUS+blocks[i].signal, &sa, NULL);
}
}