signal.hpp 991 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #pragma once
  2. #include <list>
  3. #include <signal.h>
  4. #include <stdint.h>
  5. #include <types/types.h>
  6. #include <types/cplusplus.hpp>
  7. namespace kernel {
  8. class signal_list {
  9. public:
  10. using signo_type = uint32_t;
  11. using list_type = std::list<signo_type>;
  12. private:
  13. list_type m_list;
  14. signo_type m_mask;
  15. sig_t m_handlers[32];
  16. public:
  17. static constexpr bool check_valid(signo_type sig)
  18. {
  19. return sig > 0 && sig < 32;
  20. }
  21. public:
  22. signal_list();
  23. constexpr signal_list(const signal_list& val) = default;
  24. constexpr signal_list(signal_list&& val) = default;
  25. void on_exec();
  26. void get_mask(sigset_t* __user mask) const;
  27. void set_mask(const sigset_t* __user mask);
  28. constexpr bool is_masked(signo_type signal) const { return m_mask & (1 << signal); }
  29. constexpr bool empty(void) const { return m_list.empty(); }
  30. void set(signo_type signal);
  31. signo_type handle();
  32. void after_signal(signo_type signal);
  33. };
  34. } // namespace kernel