SOCK_CLOEXEC should get ENOSYS, not EINVAL, on accept()
In #5112 (moved) we added a bunch of checks to ignore open(), accept4(), etc failures if errno is EINVAL.
But it would appear the accept4() sets errno to ENOSYS, not EINVAL, if the system lacks O_CLOEXEC support.
A quick google led me to https://projects.honeynet.org/svn/sebek/virtualization/qebek/trunk/osdep.c which handles EINVAL in most cases but ENOSYS in the accept4() case.
Here's the simple patch, but it probably wants a changes stanza and a much better explanation in the comment if we like it:
diff --git a/src/common/compat.c b/src/common/compat.c
index fbb37ce..490deea 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -1016,7 +1016,7 @@ tor_accept_socket(tor_socket_t sockfd, struct sockaddr *
/* If we got an error, see if it is EINVAL. EINVAL might indicate that,
* event though we were built on a system with accept4 support, we
* are running on one without. */
- if (errno != EINVAL)
+ if (errno != ENOSYS)
return s;
#endif
See also http://osdir.com/ml/ruby-talk/2012-03/msg00082.html
Reported by murb.