Opened 12 years ago
Closed 12 years ago
#4167 closed Feature Requests (wontfix)
RFC: asio::io_service::async_stop() to handle signals
Reported by: | Owned by: | chris_kohlhoff | |
---|---|---|---|
Milestone: | Boost 1.43.0 | Component: | asio |
Version: | Boost 1.42.0 | Severity: | Problem |
Keywords: | signal, event loop | Cc: |
Description
Problem statement
asio::io_service has no way of stopping from within a signal handler. Sending a signal to a daemon is a common way to controlling its behavior (under POSIX). Calling { io_service.stop(); } from a signal handler is not guaranteed to be safe.
Implementation suggestion
Declare and implement a public interface with the following semantics:
void io_service::async_stop(void);
/ Sets an internal flag in io_service to stop at the nearest event loop. May be called from a signal handler. */
Known workarounds
Let the io_service listen to a pipe. Write to the pipe from within the signal handler.
References
<URL:http://article.gmane.org/gmane.comp.lib.boost.user/58164>
Change History (1)
comment:1 by , 12 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Type: | Bugs → Feature Requests |
Thanks for the suggestion, but I do not consider this the right approach for handling signals. The "correct" way would be to handle signals just like other asynchronous events. I will probably add this support at some point.
In the meantime, you could use a pipe (as you said), but you can also process the signals synchronously using sigwait(). All of the HTTP server examples take this approach.