Boost logo

Boost Users :

Subject: [Boost-users] aiso signal handling, daemon shutdown
From: Kraus Philipp (philipp.kraus_at_[hidden])
Date: 2012-07-13 15:12:36


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.html

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

Phil



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