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 /include | |
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 'include')
-rw-r--r-- | include/fuse_common.h | 17 | ||||
-rw-r--r-- | include/fuse_log.h | 12 |
2 files changed, 29 insertions, 0 deletions
diff --git a/include/fuse_common.h b/include/fuse_common.h index 04ecb95..6de2640 100644 --- a/include/fuse_common.h +++ b/include/fuse_common.h @@ -955,6 +955,23 @@ ssize_t fuse_buf_copy(struct fuse_bufvec *dst, struct fuse_bufvec *src, int fuse_set_signal_handlers(struct fuse_session *se); /** + * Print a stack backtrace diagnostic on critical signals () + * + * Stores session in a global variable. May only be called once per + * process until fuse_remove_signal_handlers() is called. + * + * Once either of the POSIX signals arrives, the signal handler calls + * fuse_session_exit(). + * + * @param se the session to exit + * @return 0 on success, -1 on failure + * + * See also: + * fuse_remove_signal_handlers() + */ +int fuse_set_fail_signal_handlers(struct fuse_session *se); + +/** * Restore default signal handlers * * Resets global session. After this fuse_set_signal_handlers() may diff --git a/include/fuse_log.h b/include/fuse_log.h index 5e112e0..c855957 100644 --- a/include/fuse_log.h +++ b/include/fuse_log.h @@ -75,6 +75,18 @@ void fuse_set_log_func(fuse_log_func_t func); */ void fuse_log(enum fuse_log_level level, const char *fmt, ...); +/** + * Switch default log handler from stderr to syslog + * + * Passed options are according to 'man 3 openlog' + */ +void fuse_log_enable_syslog(const char *ident, int option, int facility); + +/** + * To be called at teardown to close syslog. +*/ +void fuse_log_close_syslog(void); + #ifdef __cplusplus } #endif |