posix_sigwaitinfo_at_most.cpp 763 B

123456789101112131415161718192021222324252627282930
  1. //
  2. // $Id$
  3. //
  4. #include<__vic/posix/thread.h>
  5. #include<__vic/throw_errno.h>
  6. #include<cerrno>
  7. namespace __vic { namespace posix {
  8. #ifdef __VIC_POSIX_RT__
  9. //----------------------------------------------------------------------------
  10. bool this_thread::sigwaitinfo_at_most(
  11. const ::sigset_t &set, const ::timespec &timeout, ::siginfo_t &si)
  12. {
  13. int sig_no = ::sigtimedwait(&set, &si, &timeout);
  14. if(sig_no >= 0) return true;
  15. switch(int err = errno)
  16. {
  17. case EAGAIN: // timeout
  18. case EINTR: // interrupted by signal other than one of those in set
  19. return false;
  20. default: throw_errno("sigtimedwait", err);
  21. }
  22. }
  23. //----------------------------------------------------------------------------
  24. #endif
  25. }} // namespace