diff options
author | Rob Landley <rob@landley.net> | 2015-03-09 14:52:32 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2015-03-09 14:52:32 -0500 |
commit | e6abb61e057d55a08c263a48648aaf7b776dfcee (patch) | |
tree | c2f91c7e62ebb259bce131e794086590b588221e /lib | |
parent | e3edd6cda410d25082135a6526cf7bfa17b49d8c (diff) | |
download | toybox-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.h | 1 | ||||
-rw-r--r-- | lib/xwrap.c | 11 |
2 files changed, 12 insertions, 0 deletions
@@ -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); +} |