aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2015-03-09 14:52:32 -0500
committerRob Landley <rob@landley.net>2015-03-09 14:52:32 -0500
commite6abb61e057d55a08c263a48648aaf7b776dfcee (patch)
treec2f91c7e62ebb259bce131e794086590b588221e /lib
parente3edd6cda410d25082135a6526cf7bfa17b49d8c (diff)
downloadtoybox-e6abb61e057d55a08c263a48648aaf7b776dfcee.tar.gz
Upgrade oneit with -r (restart), -3 (send exiting PID values to child), and signal handling.
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);
+}