$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: [boost] extending asio with unix signal handlers
From: Dmitry Goncharov (dgoncharov_at_[hidden])
Date: 2009-03-19 04:55:27
Hi,
What do you think of extending asio with unix signal handling?
The extension lets the library user to have a handler invoked when a
unix signal arrives.
void on_signal(boost::system::error_code const& error)
{
if (!error)
cout << "sigint received" << endl;
}
int main(int argc, char const* argv[])
{
boost::asio::io_service ios;
boost::asio::posix::signal_handler<SIGINT> sigint(ios);
while (true)
{
ios.reset();
sigint.async_wait(boost::bind(on_signal, _1));
ios.poll();
}
}
This lets the user have a unix signal handler of an arbitrary signature.
This also removes the "async-signal safe calls" restriction.
Please, find the implementation along with two examples enclosed.
BR, Dmitry