aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/lib.h1
-rw-r--r--lib/xwrap.c11
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/lib.h b/lib/lib.h
index a183fd56..e5667517 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -129,6 +129,7 @@ long xparsetime(char *arg, long units, long *fraction);
void xpidfile(char *name);
void xregcomp(regex_t *preg, char *rexec, int cflags);
char *xtzset(char *new);
+void xsignal(int signal, void *handler);
// lib.c
void verror_msg(char *msg, int err, va_list va);
diff --git a/lib/xwrap.c b/lib/xwrap.c
index 14703a72..44cd1684 100644
--- a/lib/xwrap.c
+++ b/lib/xwrap.c
@@ -638,3 +638,14 @@ char *xtzset(char *new)
return tz;
}
+
+// Set a signal handler
+void xsignal(int signal, void *handler)
+{
+ struct sigaction *sa = (void *)libbuf;
+
+ memset(sa, 0, sizeof(struct sigaction));
+ sa->sa_handler = handler;
+
+ if (sigaction(signal, sa, 0)) perror_exit("xsignal %d", signal);
+}