signal_init.hpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // detail/signal_init.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef BOOST_ASIO_DETAIL_SIGNAL_INIT_HPP
  11. #define BOOST_ASIO_DETAIL_SIGNAL_INIT_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <boost/asio/detail/config.hpp>
  16. #if !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
  17. #include <csignal>
  18. #include <boost/asio/detail/push_options.hpp>
  19. namespace boost {
  20. namespace asio {
  21. namespace detail {
  22. template <int Signal = SIGPIPE>
  23. class signal_init
  24. {
  25. public:
  26. // Constructor.
  27. signal_init()
  28. {
  29. std::signal(Signal, SIG_IGN);
  30. }
  31. };
  32. } // namespace detail
  33. } // namespace asio
  34. } // namespace boost
  35. #include <boost/asio/detail/pop_options.hpp>
  36. #endif // !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__)
  37. #endif // BOOST_ASIO_DETAIL_SIGNAL_INIT_HPP