aboutsummaryrefslogtreecommitdiff
path: root/src/handler.cc
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-09-01 06:21:08 +0000
committer_ov4 <ov4@ov4.org>2026-09-01 06:21:08 +0000
commitc9c3b2f4357e30dd078075b3259d86adca6958e3 (patch)
tree30c826381261333a0f78d87b41e176e148ddd68f /src/handler.cc
parentd77e0e13d3624f6210fee3317a5677b2d705a19f (diff)
1
Diffstat (limited to 'src/handler.cc')
-rw-r--r--src/handler.cc23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/handler.cc b/src/handler.cc
index afc1fc1..5356d47 100644
--- a/src/handler.cc
+++ b/src/handler.cc
@@ -6,12 +6,33 @@ namespace ov4
extern char **environ;
sigset_t BLOCK_HANDLER;
-void init()
+void signal_init()
{
sigemptyset(&BLOCK_HANDLER);
sigaddset(&BLOCK_HANDLER, SIGINT);
sigaddset(&BLOCK_HANDLER, SIGTSTP);
sigaddset(&BLOCK_HANDLER, SIGCHLD);
+
+ Signal(SIGINT, sigint_handler); /* ctrl-c */
+ Signal(SIGTSTP, sigtstp_handler); /* ctrl-z */
+ Signal(SIGCHLD, sigchld_handler); /* Terminated or stopped child */
+}
+
+/*
+ * Signal - wrapper for the sigaction function
+ */
+
+handler_t *Signal(int signum, handler_t *handler)
+{
+ struct sigaction action, old_action;
+
+ action.sa_handler = handler;
+ sigemptyset(&action.sa_mask); /* block sigs of type being handled */
+ action.sa_flags = SA_RESTART; /* restart syscalls if possible */
+
+ if (sigaction(signum, &action, &old_action) < 0)
+ unix_error("Signal error");
+ return (old_action.sa_handler);
}
/*