CernVM-FS
2.12.0
|
#include <monitor.h>
Classes | |
struct | ControlFlow |
struct | CrashData |
Public Types | |
typedef void(* | FnOnCrash )(void) |
Public Member Functions | |
~Watchdog () | |
void | Spawn (const std::string &crash_dump_path) |
Static Public Member Functions | |
static Watchdog * | Create (FnOnCrash on_crash) |
static pid_t | GetPid () |
Static Public Attributes | |
static int | g_suppressed_signals [13] |
static int | g_crash_signals [8] |
Private Types | |
typedef std::map< int, struct sigaction > | SigactionMap |
Private Member Functions | |
Watchdog (FnOnCrash on_crash) | |
void | Fork () |
bool | WaitForSupervisee () |
SigactionMap | SetSignalHandlers (const SigactionMap &signal_handlers) |
void | Supervise () |
void | LogEmergency (std::string msg) |
std::string | ReportStacktrace () |
std::string | GenerateStackTrace (pid_t pid) |
std::string | ReadUntilGdbPrompt (int fd_pipe) |
Private Member Functions inherited from SingleCopy | |
SingleCopy () | |
Static Private Member Functions | |
static Watchdog * | Me () |
static void * | MainWatchdogListener (void *data) |
static void | ReportSignalAndTerminate (int sig, siginfo_t *siginfo, void *context) |
static void | SendTrace (int sig, siginfo_t *siginfo, void *context) |
Private Attributes | |
bool | spawned_ |
std::string | crash_dump_path_ |
std::string | exe_path_ |
pid_t | watchdog_pid_ |
UniquePtr< Pipe< kPipeWatchdog > > | pipe_watchdog_ |
UniquePtr< Pipe < kPipeWatchdogSupervisor > > | pipe_listener_ |
The supervisee makes sure its watchdog does not die. More... | |
UniquePtr< Pipe < kPipeThreadTerminator > > | pipe_terminate_ |
Send the terminate signal to the listener. More... | |
pthread_t | thread_listener_ |
FnOnCrash | on_crash_ |
platform_spinlock | lock_handler_ |
stack_t | sighandler_stack_ |
SigactionMap | old_signal_handlers_ |
Static Private Attributes | |
static const unsigned | kSignalHandlerStacksize = 2 * 1024 * 1024 |
static const unsigned | kMaxBacktrace = 64 |
static Watchdog * | instance_ = NULL |
This file is part of the CernVM File System. This class can fork a watchdog process that listens on a pipe and prints a stackstrace into syslog, when cvmfs fails. The crash dump is also appended to the crash dump file, if the path is not empty. Singleton.
The watchdog process if forked on Create and put on hold. Spawn() will start the supervision and set the crash dump path. It should be called from the final supervisee pid (after daemon etc.) but preferably before any threads are started.
Note: logging should be set up before calling Create()
typedef void(* Watchdog::FnOnCrash)(void) |
|
private |
Watchdog::~Watchdog | ( | ) |
|
explicitprivate |
Definition at line 70 of file monitor.cc.
Referenced by cvmcache_spawn_watchdog(), Init(), main(), swissknife::CommandSync::Main(), and PosixQuotaManager::MainCacheManager().
|
private |
Fork the watchdog process and put it on hold until Spawn() is called.
Definition at line 387 of file monitor.cc.
|
private |
Uses an external shell and gdb to create a full stack trace of the dying process. The same shell is used to force-quit the client afterwards.
Definition at line 82 of file monitor.cc.
|
static |
Definition at line 172 of file monitor.cc.
Referenced by TalkManager::MainResponder().
|
private |
Log a string to syslog and into the crash dump file. We expect ideally nothing to be logged, so that file is created on demand.
Definition at line 183 of file monitor.cc.
|
staticprivate |
|
private |
Reads from the file descriptor until the specific gdb prompt is reached or the pipe gets broken.
fd_pipe | the file descriptor of the pipe to be read |
Definition at line 212 of file monitor.cc.
|
staticprivate |
|
private |
Generates useful information from the backtrace log in the pipe.
Definition at line 251 of file monitor.cc.
|
staticprivate |
|
private |
Sets the signal handlers of the current process according to the ones defined in the given SigactionMap.
signal_handlers | a map of SIGNAL -> struct sigaction |
Definition at line 366 of file monitor.cc.
Referenced by MainWatchdogListener().
void Watchdog::Spawn | ( | const std::string & | crash_dump_path | ) |
Set up the signal handling and kick off the supervision.
Definition at line 510 of file monitor.cc.
Referenced by cvmcache_spawn_watchdog(), main(), swissknife::CommandSync::Main(), PosixQuotaManager::MainCacheManager(), and Spawn().
|
private |
|
private |
|
static |
|
static |
Signals that watchdog should not receive. If it does, report and exit.
Definition at line 48 of file monitor.h.
Referenced by AuthzExternalFetcher::ExecHelper().
|
staticprivate |
Definition at line 83 of file monitor.h.
Referenced by Me(), and ~Watchdog().
|
staticprivate |
|
staticprivate |
|
private |
Definition at line 113 of file monitor.h.
Referenced by Watchdog(), and ~Watchdog().
|
private |
Definition at line 115 of file monitor.h.
Referenced by MainWatchdogListener().
|
private |
The supervisee makes sure its watchdog does not die.
Definition at line 108 of file monitor.h.
Referenced by MainWatchdogListener(), and ~Watchdog().
|
private |
Send the terminate signal to the listener.
Definition at line 110 of file monitor.h.
Referenced by MainWatchdogListener(), and ~Watchdog().
|
private |
Definition at line 106 of file monitor.h.
Referenced by ~Watchdog().
|
private |
Definition at line 114 of file monitor.h.
Referenced by Watchdog(), and ~Watchdog().
|
private |
Definition at line 102 of file monitor.h.
Referenced by ~Watchdog().
|
private |
Definition at line 111 of file monitor.h.
Referenced by ~Watchdog().