Boost logo

Boost Users :

Subject: Re: [Boost-users] catch real time signals
From: Halim DJERROUD (halim.contact_at_[hidden])
Date: 2014-08-14 11:27:42


Thank you very much John,
You solved my problem
I undestant , run() indeed stops the service after having received the
first signal.
Within handler(), we need to call another async_wait(), to keep the loop
running - as long as there's at least one async event to wait for, the loop
is running. When all events have been completed, the loop ends.
Thanks

2014-08-14 1:11 GMT+02:00 Gavin Lambert <gavinl_at_[hidden]>:

> 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 mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

-- 
Cordialement
Halim DJERROUD


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