O_CLOEXEC flag used in ip.cpp:192 is supported only on Linux kernels 2.6.27+


When building ZeroMQ versions 2.1.10+ build system have to check whether the underlying kernel version is actually 2.6.27 or newer (or maybe check it on runtime), even if the O_CLOEXEC flag is defined. Some virtualization environment, like OpenVZ, allow to run newer Linux systems (like Lucid) on older host systems (like Hardy), which will end up in new libc dev headers with O_CLOEXEC defined running on older kernel which doesn't support it, which in order will block all TCP communications due to an inability to bind a socket at all.




Martin Lucina
January 25, 2012, 5:55 AM

Closing as fixed since Ubuntu guys will use their own downstream patch

Julian Taylor
January 20, 2012, 5:43 PM

there is nothing one can further do when there is no CLOEXEC. A socket without CLOEXEC is better than none at all.
The #ifdef will never be true on ubuntu systems with zeromq anyway.

Martin Lucina
January 20, 2012, 12:53 AM

Thanks for the patch, are you sure you want this commented out?

@@ -201,7 +207,8 @@ int zmq::open_socket (int domain_, int t
// between socket creation and this point).
#if !defined SOCK_CLOEXEC && defined FD_CLOEXEC
int rc = fcntl (s, F_SETFD, FD_CLOEXEC);

  • errno_assert (rc != -1);
    + /* ignore to be able to run build testsuites on hardy builders
    + errno_assert (rc != -1); */

Julian Taylor
January 19, 2012, 5:53 PM

yes you can close it fixed if you don't want to use a runtime check.
I have attached the patch I'm going to apply to ubuntu (based on 2.1.10)

Julian Taylor
January 19, 2012, 5:51 PM

runtime SOCK_CLOEXEC check, based on 2.1.10



Martin Sustrik


Andrey Sibiryov




Affects versions