Boost logo

Boost Users :

Subject: Re: [Boost-users] aiso signal handling, daemon shutdown
From: Casimiro, Daniel C CIV NUWC NWPT (daniel.casimiro_at_[hidden])
Date: 2012-07-13 16:05:24


> Hello,
>
> I try to create a working example for a daemon with
>
http://www.boost.org/doc/libs/1_50_0/doc/html/boost_asio/overview/signals.ht
ml
>
> I have created a program like:
>
> static bool run = true;
>
> void handler( const boost::system::error_code& error, int signal_number) {
> if (!error)
> {
> run = false;
> std::cout << "signal" << std::endl;
> }
> }
>
>
> and the main with
>
> int main(..) {
> boost::asio::io_service io_service;
> boost::asio::signal_set signals(io_service, SIGINT, SIGTERM);
> signals.async_wait(handler);
>
> while (run) { boost::this_thread::yield(); } }
>
>
> The program runs, but if I do "kill pid" the program does not stop or
shows the message.
> I would like to create a small daemon which runs some threads and can stop
with the normal stop signal and can reload the
> configuration on reload.
>
> Can anyone help me to create a working example first !?
> Thanks a lot
>

Your asynchronous handlers are not running because you forgot to call "
io_service.run()."

~Dan




Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net