[zeromq-dev] exception from recv()

Andrew Hume andrew at research.att.com
Thu Sep 27 20:21:15 CEST 2012

yes, you can get EINTR for a few reasons
and EAGAIN for a host of reasons.
mac os/x is particularly prone to this for some reason.
because of this, i never use a raw recv, i use this wrapper:

mrecv(void *sock, zmq_msg_t *msg, int flags)
	assert(zmq_msg_init(msg) == 0);
	while(zmq_recv(sock, msg, flags) < 0){
		if(errno == EINTR){
		if(errno == EAGAIN){
			if(flags & ZMQ_NOBLOCK)
				return -1;
		fprintf(stderr, "error on socket %p; ", sock);
	return 0;

On Sep 27, 2012, at 10:21 AM, Ian Barber wrote:

> On Thu, Sep 27, 2012 at 4:11 PM, Tom Wilberding <tom at wilberding.com> wrote:
>> Thanks Ian but my reading of zmq.hpp and the release notes is that it is
>> throwing if it isn't EGAIN (not EINTR). I looked at the java bindings
>> they have similar logic.
> Ah yes, you're right, sorry, careless reading.
>> I should also point out that I have no idea what is the root cause of
>> the interrupted system call. It can run for hours without it occurring,
>> but I've found a few ways to induce it to happen, so if anyone has some
>> debugging tips, I'd appreciate the help. I'm not sending SIGINT/^C to my
>> app, there is something else going on. Is receiving EINTR during a
>> zmq_recv() for anything other than a SIGINT/^C something that others are
>> familiar with?
> Do vaguely recall Andrew Hume having an issue of a similar nature -
> might be worth searching the list archives.
> Ian
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Andrew Hume  (best -> Telework) +1 623-551-2845
andrew at research.att.com  (Work) +1 973-236-2014
AT&T Labs - Research; member of USENIX and LOPSA

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20120927/664ce91c/attachment.htm>

More information about the zeromq-dev mailing list