Boost logo

Boost Users :

Subject: Re: [Boost-users] catch real time signals
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2014-08-13 19:11:16


On 12/08/2014 04:14, Halim DJERROUD wrote:
> I try to intercept real-time signals (SIGMIN + 1, SIGMIN +2 ...) it
> works when I send a signal (kill -35 PID)
> it works well only if i send one signal, when i send another signal or
> same signal second time (kill -35 PID) the pogram does not intercept
> the signal
[...]
> #define SIG1 (SIGRTMIN + 1)
> #define SIG1 (SIGRTMIN + 2)

I'm assuming that's a typo.

> signals.async_wait( boost::bind(&Agent::signal_handler, this,
> boost::asio::placeholders::error,
> boost::asio::placeholders::signal_number));
> io_serv.run();
> for (;;) {
> std::this_thread::yield();
> }

async_wait is an operation that will wait for a single signal and then
call the hander. Once this has been done, the operation is complete.

If you want to be able to catch multiple signals, you need to call
async_wait again within your signal handler to start a new operation.

You can either call async_wait at the top of your signal handler to
potentially process signals in parallel (if you have more than one
io_service thread), or you can call it at the bottom to ensure that
signals cannot be processed concurrently (albeit possibly not on the
same thread, again).

Also bear in mind that your threads implementation might be using some
of the RT signals already, so make sure you don't collide with them.


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