voidhandler(constboost::system::error_code&error,intsignal_number){if(!error){// A signal occurred.}}...// Construct a signal set registered for process termination.boost::asio::signal_setsignals(io_service,SIGINT,SIGTERM);// Start an asynchronous wait for one of the signals to occur.signals.async_wait(handler);

If a signal is registered with a signal_set, and the signal occurs when there
are no waiting handlers, then the signal notification is queued. The next
async_wait operation on that signal_set will dequeue the notification. If
multiple notifications are queued, subsequent async_wait operations dequeue
them one at a time. Signal notifications are dequeued in order of ascending
signal number.

If a signal number is removed from a signal_set (using the remove or erase
member functions) then any queued notifications for that signal are discarded.

POSIX allows signals to be blocked using functions such as sigprocmask()
and pthread_sigmask().
For signals to be delivered, programs must ensure that any signals registered
using signal_set objects are unblocked in at least one thread.