posix_ignore_signals.cpp 664 B

1234567891011121314151617181920212223242526
  1. //
  2. // $Id$
  3. //
  4. #include<__vic/posix/process.h>
  5. #include<__vic/string_buffer.h>
  6. #include<__vic/throw_errno.h>
  7. #include<signal.h>
  8. namespace __vic { namespace posix {
  9. //----------------------------------------------------------------------------
  10. void ignore_signals(const int sigs[], size_t n)
  11. {
  12. struct ::sigaction sa;
  13. sa.sa_handler = SIG_IGN;
  14. ::sigemptyset(&sa.sa_mask);
  15. sa.sa_flags = 0;
  16. for(const int *s = sigs; n--; s++)
  17. if(::sigaction(*s, &sa, nullptr)) throw_errno(__vic::msg(32) <<
  18. "Ignoring signo " << *s << " failed");
  19. }
  20. //----------------------------------------------------------------------------
  21. }} // namespace