libcosmos
Linux C++ System Programming Library
All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
types.cxx
1// C++
2#include <ostream>
3
4// cosmos
5#include <cosmos/formatting.hxx>
6#include <cosmos/proc/signal.hxx>
7#include <cosmos/proc/SigSet.hxx>
8#include <cosmos/proc/types.hxx>
9#include <cosmos/utils.hxx>
10
11// Linux
12#include <string.h> /* strsignal() */
13
14namespace cosmos {
15
16std::string Signal::name() const {
17 return strsignal(to_integral(m_sig));
18}
19
20/* we want to be able to placement-new SigSet on top of raw sigset_t */
21static_assert(sizeof(SigSet) == sizeof(sigset_t), "bad SigSet size");
22
23} // end ns
24
25std::ostream& operator<<(std::ostream &o, const cosmos::Signal sig) {
26 o << sig.name() << " (" << sig.raw() << ")";
27
28 return o;
29}
A bit set of signal numbers for use in system calls.
Definition SigSet.hxx:25
Represents a POSIX signal number and offers a minimal API around it.
Definition types.hxx:96
std::string name() const
Returns a human readable label for the currently stored signal number.
Definition types.cxx:16
SignalNr raw() const
Returns the primitive signal number stored in this object.
Definition types.hxx:115
SignalNr m_sig
The raw signal number.
Definition types.hxx:127