diff options
author | Bernd Schubert <bschubert@ddn.com> | 2024-07-10 23:04:46 +0200 |
---|---|---|
committer | Bernd Schubert <bernd.schubert@fastmail.fm> | 2024-07-14 14:28:44 +0200 |
commit | dae1184302834b52cff438fbf5322cd1c9c79c06 (patch) | |
tree | 3c71a7f60f442d460f5968e239ab0ed2a0defe27 /example/passthrough_hp.cc | |
parent | 67ce439e2d73e73426b68695288729c6ffd63e5b (diff) | |
download | libfuse-dae1184302834b52cff438fbf5322cd1c9c79c06.tar.gz |
Add syslog and fatal signal handler feature
I see random ENOTCONN failures in xfstest generic/013 and generic/014
in my branch, but earliest on the 2nd run - takes ~12hours to get
the issue, but then there are no further information logged.
ENOTCONN points to a daemon crash - I need backtraces and a core dump.
This adds optional handling of fatal signals to print a core dump
and optional syslog logging with these new public functions:
fuse_set_fail_signal_handlers()
In addition to the existing fuse_set_signal_handlers(). This is not
enabled together with fuse_set_signal_handlers(), as it is change
in behavior and file systems might already have their own fatal
handlers.
fuse_log_enable_syslog
Print logs to syslog instead of stderr
fuse_log_close_syslog
Close syslog (for now just does closelog())
Code in fuse_signals.c is also updated, to be an array of signals,
and setting signal handlers is now down with a for-loop instead
of one hand coded set_one_signal_handler() per signal.
Diffstat (limited to 'example/passthrough_hp.cc')
-rw-r--r-- | example/passthrough_hp.cc | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/example/passthrough_hp.cc b/example/passthrough_hp.cc index e3c8225..708a38e 100644 --- a/example/passthrough_hp.cc +++ b/example/passthrough_hp.cc @@ -75,6 +75,7 @@ #include <fstream> #include <thread> #include <iomanip> +#include <syslog.h> using namespace std; @@ -1436,6 +1437,9 @@ int main(int argc, char *argv[]) { if (fuse_set_signal_handlers(se) != 0) goto err_out2; + if (fuse_set_fail_signal_handlers(se) != 0) + goto err_out2; + // Don't apply umask, use modes exactly as specified umask(0); @@ -1452,12 +1456,14 @@ int main(int argc, char *argv[]) { fuse_daemonize(fs.foreground); + if (!fs.foreground) + fuse_log_enable_syslog("passthrough-hp", LOG_PID | LOG_CONS, LOG_DAEMON); + if (options.count("single")) ret = fuse_session_loop(se); else ret = fuse_session_loop_mt(se, loop_config); - fuse_session_unmount(se); err_out3: @@ -1469,6 +1475,9 @@ err_out1: fuse_loop_cfg_destroy(loop_config); fuse_opt_free_args(&args); + if (!fs.foreground) + fuse_log_close_syslog(); + return ret ? 1 : 0; } |