2 / Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
4 / Distributed under the Boost Software License, Version 1.0. (See accompanying
5 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 [section:signals Signal Handling]
10 Boost.Asio supports signal handling using a class called [link
11 boost_asio.reference.signal_set signal_set]. Programs may add one or more signals to
12 the set, and then perform an `async_wait()` operation. The specified handler
13 will be called when one of the signals occurs. The same signal number may be
14 registered with multiple [link boost_asio.reference.signal_set signal_set] objects,
15 however the signal number must be used only with Boost.Asio.
18 const boost::system::error_code& error,
29 // Construct a signal set registered for process termination.
30 boost::asio::signal_set signals(io_service, SIGINT, SIGTERM);
32 // Start an asynchronous wait for one of the signals to occur.
33 signals.async_wait(handler);
35 Signal handling also works on Windows, as the Microsoft Visual C++ runtime
36 library maps console events like Ctrl+C to the equivalent signal.
40 [link boost_asio.reference.signal_set signal_set],
41 [link boost_asio.examples.cpp03_examples.http_server HTTP server example (C++03)],
42 [link boost_asio.examples.cpp11_examples.http_server HTTP server example (C++11)].