summaryrefslogtreecommitdiffstats
path: root/fuse/fuse_signals.c
diff options
context:
space:
mode:
authorMatt Mower <mowerm@gmail.com>2015-12-13 18:31:00 +0100
committerEthan Yonker <dees_troy@teamw.in>2015-12-23 16:58:04 +0100
commit523a059fb7d5844ebcca279b2f83aff9164b444c (patch)
tree4353fa9fa64a17ef2c5548f0c9f73f5e5f389f6a /fuse/fuse_signals.c
parentexfat: Update to 1.2.2 (diff)
downloadandroid_bootable_recovery-523a059fb7d5844ebcca279b2f83aff9164b444c.tar
android_bootable_recovery-523a059fb7d5844ebcca279b2f83aff9164b444c.tar.gz
android_bootable_recovery-523a059fb7d5844ebcca279b2f83aff9164b444c.tar.bz2
android_bootable_recovery-523a059fb7d5844ebcca279b2f83aff9164b444c.tar.lz
android_bootable_recovery-523a059fb7d5844ebcca279b2f83aff9164b444c.tar.xz
android_bootable_recovery-523a059fb7d5844ebcca279b2f83aff9164b444c.tar.zst
android_bootable_recovery-523a059fb7d5844ebcca279b2f83aff9164b444c.zip
Diffstat (limited to 'fuse/fuse_signals.c')
-rw-r--r--fuse/fuse_signals.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/fuse/fuse_signals.c b/fuse/fuse_signals.c
index 88ac39e18..353cb24bd 100644
--- a/fuse/fuse_signals.c
+++ b/fuse/fuse_signals.c
@@ -21,13 +21,13 @@ static void exit_handler(int sig)
fuse_session_exit(fuse_instance);
}
-static int set_one_signal_handler(int sig, void (*handler)(int))
+static int set_one_signal_handler(int sig, void (*handler)(int), int remove)
{
struct sigaction sa;
struct sigaction old_sa;
memset(&sa, 0, sizeof(struct sigaction));
- sa.sa_handler = handler;
+ sa.sa_handler = remove ? SIG_DFL : handler;
sigemptyset(&(sa.sa_mask));
sa.sa_flags = 0;
@@ -36,7 +36,7 @@ static int set_one_signal_handler(int sig, void (*handler)(int))
return -1;
}
- if (old_sa.sa_handler == SIG_DFL &&
+ if (old_sa.sa_handler == (remove ? handler : SIG_DFL) &&
sigaction(sig, &sa, NULL) == -1) {
perror("fuse: cannot set signal handler");
return -1;
@@ -46,10 +46,10 @@ static int set_one_signal_handler(int sig, void (*handler)(int))
int fuse_set_signal_handlers(struct fuse_session *se)
{
- if (set_one_signal_handler(SIGHUP, exit_handler) == -1 ||
- set_one_signal_handler(SIGINT, exit_handler) == -1 ||
- set_one_signal_handler(SIGTERM, exit_handler) == -1 ||
- set_one_signal_handler(SIGPIPE, SIG_IGN) == -1)
+ if (set_one_signal_handler(SIGHUP, exit_handler, 0) == -1 ||
+ set_one_signal_handler(SIGINT, exit_handler, 0) == -1 ||
+ set_one_signal_handler(SIGTERM, exit_handler, 0) == -1 ||
+ set_one_signal_handler(SIGPIPE, SIG_IGN, 0) == -1)
return -1;
fuse_instance = se;
@@ -64,9 +64,9 @@ void fuse_remove_signal_handlers(struct fuse_session *se)
else
fuse_instance = NULL;
- set_one_signal_handler(SIGHUP, SIG_DFL);
- set_one_signal_handler(SIGINT, SIG_DFL);
- set_one_signal_handler(SIGTERM, SIG_DFL);
- set_one_signal_handler(SIGPIPE, SIG_DFL);
+ set_one_signal_handler(SIGHUP, exit_handler, 1);
+ set_one_signal_handler(SIGINT, exit_handler, 1);
+ set_one_signal_handler(SIGTERM, exit_handler, 1);
+ set_one_signal_handler(SIGPIPE, SIG_IGN, 1);
}