Sha256: c59f3ab8e7aa41d3335fe5975ca689763e59a6aeee1f5950ddc936b6867cc259

Contents?: true

Size: 1.41 KB

Versions: 24

Compression:

Stored size: 1.41 KB

Contents

[/
 / Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com)
 /
 / Distributed under the Boost Software License, Version 1.0. (See accompanying
 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 /]

[section:signals Signal Handling]

Asio supports signal handling using a class called [link
asio.reference.signal_set signal_set]. Programs may add one or more signals to
the set, and then perform an `async_wait()` operation. The specified handler
will be called when one of the signals occurs. The same signal number may be
registered with multiple [link asio.reference.signal_set signal_set] objects,
however the signal number must be used only with Asio.

  void handler(
      const asio::error_code& error,
      int signal_number)
  {
    if (!error)
    {
      // A signal occurred.
    }
  }

  ...

  // Construct a signal set registered for process termination.
  asio::signal_set signals(io_context, SIGINT, SIGTERM);

  // Start an asynchronous wait for one of the signals to occur.
  signals.async_wait(handler);

Signal handling also works on Windows, as the Microsoft Visual C++ runtime
library maps console events like Ctrl+C to the equivalent signal.

[heading See Also]

[link asio.reference.signal_set signal_set],
[link asio.examples.cpp03_examples.http_server HTTP server example (C++03)],
[link asio.examples.cpp11_examples.http_server HTTP server example (C++11)].

[endsect]

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
couchbase-3.0.0-universal-darwin-19 ext/third_party/asio/asio/src/doc/overview/signals.qbk
couchbase-3.0.0 ext/third_party/asio/asio/src/doc/overview/signals.qbk
couchbase-3.0.0.beta.1-universal-darwin-19 ext/third_party/asio/asio/src/doc/overview/signals.qbk
couchbase-3.0.0.beta.1 ext/third_party/asio/asio/src/doc/overview/signals.qbk
couchbase-3.0.0.alpha.5-x86_64-linux ext/third_party/asio/asio/src/doc/overview/signals.qbk
couchbase-3.0.0.alpha.5-universal-darwin-19 ext/third_party/asio/asio/src/doc/overview/signals.qbk
couchbase-3.0.0.alpha.5-x86_64-darwin-19 ext/third_party/asio/asio/src/doc/overview/signals.qbk
couchbase-3.0.0.alpha.5 ext/third_party/asio/asio/src/doc/overview/signals.qbk
couchbase-3.0.0.alpha.4-x86_64-linux ext/third_party/asio/asio/src/doc/overview/signals.qbk
couchbase-3.0.0.alpha.4-x86_64-darwin-19 ext/third_party/asio/asio/src/doc/overview/signals.qbk
couchbase-3.0.0.alpha.4-universal-darwin-19 ext/third_party/asio/asio/src/doc/overview/signals.qbk
couchbase-3.0.0.alpha.4 ext/third_party/asio/asio/src/doc/overview/signals.qbk
couchbase-3.0.0.alpha.3-x86_64-linux ext/third_party/asio/asio/src/doc/overview/signals.qbk
couchbase-3.0.0.alpha.3-x86_64-darwin-19 ext/third_party/asio/asio/src/doc/overview/signals.qbk
couchbase-3.0.0.alpha.3-universal-darwin-19 ext/third_party/asio/asio/src/doc/overview/signals.qbk
couchbase-3.0.0.alpha.3 ext/third_party/asio/asio/src/doc/overview/signals.qbk
couchbase-3.0.0.alpha.2-x86_64-linux ext/third_party/asio/asio/src/doc/overview/signals.qbk
couchbase-3.0.0.alpha.2-x86_64-darwin-19 ext/third_party/asio/asio/src/doc/overview/signals.qbk
couchbase-3.0.0.alpha.2-universal-darwin-19 ext/third_party/asio/asio/src/doc/overview/signals.qbk
couchbase-3.0.0.alpha.2 ext/third_party/asio/asio/src/doc/overview/signals.qbk