Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
crash.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Roc authors
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
8 
9 //! @file roc_core/target_posix/roc_core/crash.h
10 //! @brief Crash handling.
11 
12 #ifndef ROC_CORE_CRASH_H_
13 #define ROC_CORE_CRASH_H_
14 
15 #include <signal.h>
16 
17 #include "roc_core/attributes.h"
18 #include "roc_core/noncopyable.h"
19 
20 namespace roc {
21 namespace core {
22 
23 //! Report a crash and abort application.
24 void crash(const char* message) ROC_ATTR_NORETURN;
25 
26 //! Crash handler.
27 class CrashHandler : public core::NonCopyable<> {
28 public:
29  //! Install signal handlers.
30  CrashHandler();
31 
32  //! Restore signal handlers.
33  ~CrashHandler();
34 
35 private:
36  void install_(int sig);
37 
38  enum { MaxSigs = 8 };
39 
40  struct sigaction sa_restore_[MaxSigs];
41  int sig_restore_[MaxSigs];
42  size_t restore_sz_;
43 };
44 
45 } // namespace core
46 } // namespace roc
47 
48 #endif // ROC_CORE_CRASH_H_
void crash(const char *message) ROC_ATTR_NORETURN
Report a crash and abort application.
CrashHandler()
Install signal handlers.
GCC attributes.
Root namespace.
#define ROC_ATTR_NORETURN
Function never returns.
Definition: attributes.h:19
Base class for non-copyable objects.
Definition: noncopyable.h:23
Non-copyable object.
Crash handler.
Definition: crash.h:27
~CrashHandler()
Restore signal handlers.