[zeromq-dev] Signal handling in blocking zmq_recv
Chris Wong
chris at chriswongstudio.com
Tue Mar 9 19:46:27 CET 2010
Martin, thanks for the pointer to the zmq-camera example. It handles SIGINT/SIGQUIT etc by exiting the process. If I want to interrupt all the blocked zmq_recv calls when receiving a SIGINT, how would you suggest me approaching this problem? zmq_recv seems to be blocked forever.
I tool a brief look at Ruby's socket API implementation. It's calling select before calling recvfrom. I suspect that the default signal handler was overridden by Ruby's runtime. If I install a ruby-level signal handler and can in turn interrupt all the blocked zmq_recv, that may be a solution. With that approach, I won't be mucking around with Ruby's internal signal handler. Seems better to me I should integrate with the Ruby's sig handler system instead of doing this at the C level.
Thoughts?
Chris
P.S.: this approach may apply similarly with Python's.
On Mar 8, 2010, at 1:29 AM, Martin Sustrik wrote:
> Brian,
>
>> Do you have a sense of what a proper signal handler would do?
>
> I wasn't solving the problem myself. Mato Lucina will give you more proper info.
>
> However, AFAIU, Python (Ruby) should block all the signals on its thread(s) and create a separate thread to call sigwait occasionally to check for the signals.
>
> See the implemetation example here:
>
> http://github.com/mato/zeromq-examples/blob/master/zmq-camera.c
>
> Martin
More information about the zeromq-dev
mailing list