diff options
author | Miklos Szeredi <miklos@szeredi.hu> | 2004-07-02 16:20:45 +0000 |
---|---|---|
committer | Miklos Szeredi <miklos@szeredi.hu> | 2004-07-02 16:20:45 +0000 |
commit | acb4d36c3c91ffc076e76bd11ef8064bd51b4716 (patch) | |
tree | d47823cd63624d9a73fb5f1e695c420d208a4b42 /lib | |
parent | ad051c3e27ca6dd57dad57eb188dbcdcfab775fe (diff) | |
download | libfuse-acb4d36c3c91ffc076e76bd11ef8064bd51b4716.tar.gz |
minor features
Diffstat (limited to 'lib')
-rw-r--r-- | lib/helper.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/lib/helper.c b/lib/helper.c index cd3cfea..526fadd 100644 --- a/lib/helper.c +++ b/lib/helper.c @@ -50,30 +50,35 @@ static void exit_handler() fuse_exit(fuse); } -static void set_signal_handlers() +static void set_one_signal_handler(int signal, void (*handler)(int)) { struct sigaction sa; + struct sigaction old_sa; - sa.sa_handler = exit_handler; + sa.sa_handler = handler; sigemptyset(&(sa.sa_mask)); sa.sa_flags = 0; - if (sigaction(SIGHUP, &sa, NULL) == -1 || - sigaction(SIGINT, &sa, NULL) == -1 || - sigaction(SIGTERM, &sa, NULL) == -1) { - - perror("Cannot set exit signal handlers"); + if (sigaction(signal, NULL, &old_sa) == -1) { + perror("FUSE: cannot get old signal handler"); exit(1); } - - sa.sa_handler = SIG_IGN; - - if (sigaction(SIGPIPE, &sa, NULL) == -1) { - perror("Cannot set ignored signals"); + + if (old_sa.sa_handler == SIG_DFL && + sigaction(signal, &sa, NULL) == -1) { + perror("Cannot set signal handler"); exit(1); } } +static void set_signal_handlers() +{ + set_one_signal_handler(SIGHUP, exit_handler); + set_one_signal_handler(SIGINT, exit_handler); + set_one_signal_handler(SIGTERM, exit_handler); + set_one_signal_handler(SIGPIPE, SIG_IGN); +} + static int fuse_start(int fuse_fd, int flags, int multithreaded, int background, const struct fuse_operations *op) { |