cpp-terminal 1.0.0
Small C++ library for writing multiplatform terminal applications
Loading...
Searching...
No Matches
Term::Private::Signals Class Reference

#include <cpp-terminal/private/signals.hpp>

Public Member Functions

 Signals (std::vector< sighandler_t > &m_han) noexcept
 
 ~Signals () noexcept
 
void setHandler (const sighandler_t &handler) noexcept
 

Static Public Member Functions

static void reset_and_raise (int sign, std::vector< sighandler_t > &m_han, Term::Terminal &) noexcept
 

Static Private Attributes

static const std::size_t m_signals_number {NSIG - 1}
 

Detailed Description

Definition at line 21 of file signals.hpp.

Constructor & Destructor Documentation

◆ Signals()

Term::Private::Signals::Signals ( std::vector< sighandler_t > & m_han)
noexcept

Definition at line 28 of file signals.cpp.

29{
30 const static std::vector<int> ignore{
31#if defined(SIGCONT)
32 SIGCONT,
33#endif
34#if defined(SIGSTOP)
35 SIGSTOP,
36#endif
37#if defined(SIGTSTP)
38 SIGTSTP,
39#endif
40#if defined(SIGTTIN)
41 SIGTTIN,
42#endif
43#if defined(SIGTTOU)
44 SIGTTOU,
45#endif
46 };
47 m_han.reserve(m_signals_number);
48 for(std::size_t signal = 0; signal != m_signals_number; ++signal)
49 {
50 //if(std::find(ignore.begin(),ignore.end(),signal)==ignore.end())
51 //{
52 sighandler_t old = std::signal(signal, SIG_DFL);
53 //sighandler_t dumb=std::signal(signal, old);
54 m_han.push_back(old);
55 //}
56 //else
57 //{
58 // std::signal(signal, SIG_IGN);
59 // m_han.push_back(std::signal(signal, SIG_IGN));
60 // }
61 }
62}
static const std::size_t m_signals_number
Definition signals.hpp:21
void(*)(int) sighandler_t
Definition signals.hpp:14

◆ ~Signals()

Term::Private::Signals::~Signals ( )
inlinenoexcept

Definition at line 25 of file signals.hpp.

25{}

Member Function Documentation

◆ reset_and_raise()

void Term::Private::Signals::reset_and_raise ( int sign,
std::vector< sighandler_t > & m_han,
Term::Terminal & term )
staticnoexcept

Definition at line 64 of file signals.cpp.

65{
66 const static std::vector<int> termin{
67#if defined(SIGHUP)
68 SIGHUP,
69#endif
70#if defined(SIGHUP)
71 SIGINT,
72#endif
73#if defined(SIGQUIT)
74 SIGQUIT,
75#endif
76#if defined(SIGQUIT)
77 SIGILL,
78#endif
79#if defined(SIGTRAP)
80 SIGTRAP,
81#endif
82#if defined(SIGTRAP)
83 SIGABRT,
84#endif
85#if defined(SIGIOT)
86 SIGIOT,
87#endif
88#if defined(SIGBUS)
89 SIGBUS,
90#endif
91#if defined(SIGBUS)
92 SIGFPE,
93#endif
94#if defined(SIGKILL)
95 SIGKILL,
96#endif
97#if defined(SIGUSR1)
98 SIGUSR1,
99#endif
100#if defined(SIGSEGV)
101 SIGSEGV,
102#endif
103#if defined(SIGUSR2)
104 SIGUSR2,
105#endif
106#if defined(SIGUSR2)
107 SIGPIPE,
108#endif
109#if defined(SIGALRM)
110 SIGALRM,
111#endif
112#if defined(SIGSTKFLT)
113 SIGSTKFLT,
114#endif
115#if defined(SIGCONT)
116 SIGCONT,
117#endif
118#if defined(SIGXCPU)
119 SIGXCPU,
120#endif
121#if defined(SIGXFSZ)
122 SIGXFSZ,
123#endif
124#if defined(SIGVTALRM)
125 SIGVTALRM,
126#endif
127#if defined(SIGPROF)
128 SIGPROF,
129#endif
130#if defined(SIGPROF)
131 SIGIO,
132#endif
133#if defined(SIGPOLL)
134 SIGPOLL,
135#endif
136#if defined(SIGPWR)
137 SIGPWR,
138#endif
139#if defined(SIGSYS)
140 SIGSYS,
141#endif
142#if defined(SIGUNUSED)
143 SIGUNUSED,
144#endif
145#if defined(SIGUNUSED)
146 SIGUNUSED,
147#endif
148#if defined(SIGTERM)
149 SIGTERM
150#endif
151 };
152 if(std::find(termin.begin(), termin.end(), sign) != termin.end())
153 {
154 sighandler_t old = std::signal(sign, m_han[sign]);
155 old = std::signal(sign, m_han[sign]);
156 term.clean();
157 std::raise(sign);
158 }
159}

◆ setHandler()

void Term::Private::Signals::setHandler ( const sighandler_t & handler)
noexcept

Definition at line 23 of file signals.cpp.

24{
25 for(std::size_t signal = 0; signal != m_signals_number; ++signal) { sighandler_t hand = std::signal(signal, handler); }
26}

Member Data Documentation

◆ m_signals_number

const std::size_t Term::Private::Signals::m_signals_number {NSIG - 1}
staticprivate

Definition at line 21 of file signals.hpp.


The documentation for this class was generated from the following files: