![]() |
CernVM-FS
2.11.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 () |
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) |
![]() | |
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 > | pipe_watchdog_ |
Communication channel from the supervisee to the watchdog. More... | |
UniquePtr< Pipe > | pipe_listener_ |
The supervisee makes sure its watchdog does not die. More... | |
UniquePtr< Pipe > | 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 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 61 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 378 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 73 of file monitor.cc.
|
static |
Definition at line 163 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 174 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 203 of file monitor.cc.
|
staticprivate |
Definition at line 280 of file monitor.cc.
|
private |
Generates useful information from the backtrace log in the pipe.
Definition at line 242 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 357 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 511 of file monitor.cc.
Referenced by cvmcache_spawn_watchdog(), main(), swissknife::CommandSync::Main(), PosixQuotaManager::MainCacheManager(), and Spawn().
|
private |
|
private |
|
staticprivate |
Definition at line 75 of file monitor.h.
Referenced by Me(), and ~Watchdog().
|
staticprivate |
|
staticprivate |
|
private |
Definition at line 106 of file monitor.h.
Referenced by Watchdog(), and ~Watchdog().
|
private |
Definition at line 108 of file monitor.h.
Referenced by MainWatchdogListener().
The supervisee makes sure its watchdog does not die.
Definition at line 101 of file monitor.h.
Referenced by MainWatchdogListener(), and ~Watchdog().
Send the terminate signal to the listener.
Definition at line 103 of file monitor.h.
Referenced by MainWatchdogListener(), and ~Watchdog().
Communication channel from the supervisee to the watchdog.
Definition at line 99 of file monitor.h.
Referenced by ~Watchdog().
|
private |
Definition at line 107 of file monitor.h.
Referenced by Watchdog(), and ~Watchdog().
|
private |
Definition at line 94 of file monitor.h.
Referenced by ~Watchdog().
|
private |
Definition at line 104 of file monitor.h.
Referenced by ~Watchdog().