13#include <cosmos/BitMask.hxx>
14#include <cosmos/memory.hxx>
15#include <cosmos/proc/PidFD.hxx>
16#include <cosmos/proc/types.hxx>
17#include <cosmos/thread/thread.hxx>
18#include <cosmos/time/types.hxx>
19#include <cosmos/utils.hxx>
27namespace cosmos::signal {
31constexpr Signal NONE = Signal{SignalNr::NONE};
32constexpr Signal HANGUP = Signal{SignalNr::HANGUP};
33constexpr Signal INTERRUPT = Signal{SignalNr::INTERRUPT};
34constexpr Signal QUIT = Signal{SignalNr::QUIT};
35constexpr Signal ILL = Signal{SignalNr::ILL};
36constexpr Signal TRAP = Signal{SignalNr::TRAP};
37constexpr Signal SYS_TRAP = Signal{SignalNr::SYS_TRAP};
38constexpr Signal ABORT = Signal{SignalNr::ABORT};
39constexpr Signal IOT = Signal{SignalNr::IOT};
40constexpr Signal BUS = Signal{SignalNr::BUS};
41constexpr Signal FPE = Signal{SignalNr::FPE};
42constexpr Signal KILL = Signal{SignalNr::KILL};
43constexpr Signal USR1 = Signal{SignalNr::USR1};
44constexpr Signal SEGV = Signal{SignalNr::SEGV};
45constexpr Signal USR2 = Signal{SignalNr::USR2};
46constexpr Signal PIPE = Signal{SignalNr::PIPE};
47constexpr Signal ALARM = Signal{SignalNr::ALARM};
48constexpr Signal TERMINATE = Signal{SignalNr::TERMINATE};
49constexpr Signal STACK_FAULT = Signal{SignalNr::STACK_FAULT};
50constexpr Signal CHILD = Signal{SignalNr::CHILD};
51constexpr Signal CONT = Signal{SignalNr::CONT};
52constexpr Signal STOP = Signal{SignalNr::STOP};
53constexpr Signal TERM_STOP = Signal{SignalNr::TERM_STOP};
54constexpr Signal TERM_INPUT = Signal{SignalNr::TERM_INPUT};
55constexpr Signal TERM_OUTPUT = Signal{SignalNr::TERM_OUTPUT};
56constexpr Signal URGENT = Signal{SignalNr::URGENT};
57constexpr Signal CPU_EXCEEDED = Signal{SignalNr::CPU_EXCEEDED};
58constexpr Signal FS_EXCEEDED = Signal{SignalNr::FS_EXCEEDED};
59constexpr Signal VIRTUAL_ALARM = Signal{SignalNr::VIRTUAL_ALARM};
60constexpr Signal PROFILING = Signal{SignalNr::PROFILING};
61constexpr Signal WIN_CHANGED = Signal{SignalNr::WIN_CHANGED};
62constexpr Signal IO_EVENT = Signal{SignalNr::IO_EVENT};
63constexpr Signal POLL = Signal{SignalNr::POLL};
64constexpr Signal POWER = Signal{SignalNr::POWER};
65constexpr Signal BAD_SYS = Signal{SignalNr::BAD_SYS};
66constexpr Signal MAXIMUM = Signal{SignalNr::MAXIMUM};
86 return to_integral(
rt_max().raw()) - to_integral(
rt_min().raw());
96COSMOS_API
void raise(
const Signal s);
115COSMOS_API
void send(
const ProcessID proc,
const Signal s, std::variant<void*, int> data);
125COSMOS_API
void send(
const PidFD pidfd,
const Signal s);
134COSMOS_API
void send(
const ProcessID proc,
const ThreadID thread,
const Signal s);
142COSMOS_API
void pause();
150COSMOS_API
void suspend(
const SigSet &mask);
287COSMOS_API
void block(
const SigSet &s,
SigSet *old =
nullptr);
290COSMOS_API
void unblock(
const SigSet &s,
SigSet *old =
nullptr);
293COSMOS_API
void set_sigmask(
const SigSet &s,
SigSet *old =
nullptr);
296COSMOS_API
void get_sigmask(
SigSet &old);
300 ::signal(to_integral(sig.
raw()), SIG_DFL);
310 ::signal(to_integral(sig.
raw()), SIG_IGN);
319 ON_STACK = SS_ONSTACK,
320 DISABLE = SS_DISABLE,
322 AUTO_DISARM = 1 << 31,
339 void setFlags(
const Flags flags) {
340 m_raw.ss_flags = flags.raw();
343 Flags getFlags()
const {
344 return Flags{m_raw.ss_flags};
352 void* getBase()
const {
358 m_raw.ss_size = size;
361 size_t getSize()
const {
362 return m_raw.ss_size;
400COSMOS_API
void set_altstack(
const Stack &stack, Stack *old =
nullptr);
407COSMOS_API
void get_altstack(Stack &old);
A typesafe bit mask representation using class enums.
A specialized FileDescriptor for pidfds.
Data type used with signal::set_action() for controlling asynchronous signal delivery.
Signal information struct used when receiving signals.
A bit set of signal numbers for use in system calls.
Represents a POSIX signal number and offers a minimal API around it.
SignalNr raw() const
Returns the primitive signal number stored in this object.
A C++ wrapper around the POSIX struct timespec coupled to a specific CLOCK type.
Data structure used for defining an alternate signal stack.
void setBase(void *base)
Sets the base pointer for the alternate signal stack.
static size_t MIN_SIZE
Minimum size an alternate signal stack needs to have.
void setSize(const size_t size)
Sets the size of the alternate signal stack found at getBase().
Flag
Settings for alternate stack setup.
Stack(const no_init_t)
Leaves underlying data uninitialized.
void zero_object(T &obj)
Completely overwrites the given object with zeroes.
SignalNr
A primitive signal number specification.
void restore(const Signal sig)
Restores the default signal handling behaviour for the given signal.
size_t num_rt_sigs()
Returns the number of available real-time signals.
WaitRes
Strong type to express timed_wait() and poll_info() results.
@ SIGNALED
a signal has been caught.
@ NO_RESULT
no signal was caught / timeout occurred.
Signal rt_min()
Returns the first real-time signal available.
void ignore(const Signal sig)
Ignore signal delivery for the given signal.
WaitRes poll_info(const SigSet &set, SigInfo &info)
Check for a pending signal from set and fill in info with signal details.
Signal rt_max()
Returns the last real-time signal available.
Type used to invoke constructors that explicitly don't zero-initialize low level data structures.