[zeromq-dev] Signal handling in blocking zmq_recv

Brian Granger ellisonbg at gmail.com
Wed Mar 10 23:47:21 CET 2010


> I thought of removing just the pthread_sigmask() calls from 0MQ but that
> actually has nothing to do with the problem, since the zmq_recv()
> implementation does a poll() (or equivalent) when blocking and will
> explicitly restart a system call if it gets EINTR back.
> The rationale behind this behaviour is that we consider EINTR a historic
> UNIX artifact we didn't want to reproduce, therefore you will *never* get
> EINTR back from any 0MQ library function.
> Unfortunately I don't see any straightforward solution to your problem.
> Reintroducing EINTR into 0MQ just seems horrible :-(

Yes, this doesn't sound like the right solution.

I have been able to get in touch with some folks who have had luck in
setting a different signal handler for Python that handles this in a
better way.  The code is currently released under GPL, but it looks
like they are willing to relicense so I can use it.  I will have to
port it to Windows and I am not sure how that will go.  But, the idea
is this:

1. Right before I call zmq_* functions, I will set this other signal handler.
2. After such a method returns, I will reset the regular Python signal handler.

Once the code is re-licensed, I will post it so others can see what it is doing.



Brian E. Granger, Ph.D.
Assistant Professor of Physics
Cal Poly State University, San Luis Obispo
bgranger at calpoly.edu
ellisonbg at gmail.com

More information about the zeromq-dev mailing list