12 #include "fuse_lowlevel.h" 20 static struct fuse_session *fuse_instance;
22 static void exit_handler(
int sig)
27 fuse_log(FUSE_LOG_ERR,
"assertion error: signal value <= 0\n");
30 fuse_instance->error = sig;
34 static void do_nothing(
int sig)
39 static int set_one_signal_handler(
int sig,
void (*handler)(
int),
int remove)
42 struct sigaction old_sa;
44 memset(&sa, 0,
sizeof(
struct sigaction));
45 sa.sa_handler =
remove ? SIG_DFL : handler;
46 sigemptyset(&(sa.sa_mask));
49 if (sigaction(sig, NULL, &old_sa) == -1) {
50 perror(
"fuse: cannot get old signal handler");
54 if (old_sa.sa_handler == (
remove ? handler : SIG_DFL) &&
55 sigaction(sig, &sa, NULL) == -1) {
56 perror(
"fuse: cannot set signal handler");
69 if (set_one_signal_handler(SIGHUP, exit_handler, 0) == -1 ||
70 set_one_signal_handler(SIGINT, exit_handler, 0) == -1 ||
71 set_one_signal_handler(SIGTERM, exit_handler, 0) == -1 ||
72 set_one_signal_handler(SIGPIPE, do_nothing, 0) == -1)
81 if (fuse_instance != se)
83 "fuse: fuse_remove_signal_handlers: unknown session\n");
87 set_one_signal_handler(SIGHUP, exit_handler, 1);
88 set_one_signal_handler(SIGINT, exit_handler, 1);
89 set_one_signal_handler(SIGTERM, exit_handler, 1);
90 set_one_signal_handler(SIGPIPE, do_nothing, 1);
int fuse_set_signal_handlers(struct fuse_session *se)
void fuse_remove_signal_handlers(struct fuse_session *se)
void fuse_log(enum fuse_log_level level, const char *fmt,...)
void fuse_session_exit(struct fuse_session *se)