diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-05-06 16:37:52 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-05-06 16:37:52 +0200 |
commit | dc9887834f0ca7d5e369096ceaa7aeb75ff308f7 (patch) | |
tree | 7cab38c4f8265dff1ef4ad161af9c37da88a1eff /src/libmdsserver/util.c | |
parent | add foreach_linked_list_node (diff) | |
download | mds-dc9887834f0ca7d5e369096ceaa7aeb75ff308f7.tar.gz mds-dc9887834f0ca7d5e369096ceaa7aeb75ff308f7.tar.bz2 mds-dc9887834f0ca7d5e369096ceaa7aeb75ff308f7.tar.xz |
add xsigaction
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | src/libmdsserver/util.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/libmdsserver/util.c b/src/libmdsserver/util.c index c4606e8..81793ae 100644 --- a/src/libmdsserver/util.c +++ b/src/libmdsserver/util.c @@ -22,6 +22,7 @@ #include <unistd.h> #include <limits.h> #include <string.h> +#include <signal.h> /** @@ -80,3 +81,28 @@ void reexec_server(int argc, char** argv, int reexeced) execv(readlink_buf, reexec_args); } + +/** + * Set up a signal trap. + * This function should only be used for common mds + * signals, and this function may choose to add + * additional behaviour depending on the signal, such + * as blocking other signals. + * + * @param signo The signal to trap + * @param function The function to run when the signal is caught + * @return Zero on success, -1 on error + */ +int xsigaction(int signo, void (*function)(int signo)) +{ + struct sigaction action; + sigset_t sigset; + + sigemptyset(&sigset); + action.sa_handler = function; + action.sa_mask = sigset; + action.sa_flags = 0; + + return sigaction(signo, &action, NULL); +} + |