From 4fdb9c10140f0affeb9eddd493868b0cbc8a5f19 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Tue, 10 Sep 2013 22:34:07 +0800 Subject: [PATCH 2/2] Allow EPROTOTYPE for SOCK_CLOEXEC but unsupported by socket/socketpair If SOCK_CLOEXEC is defined (usually because accept4 is implemented), check for EPROTOTYPE (the POSIX errno for invalid socket types) in addition to EINVAL as errno indicating whether socket and socketpair do not support SOCK_CLOEXEC (and other SOCK_* flags). --- dbus/dbus-sysdeps-unix.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 1face5c..9267c6e 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -144,7 +144,7 @@ _dbus_open_socket (int *fd_p, cloexec_done = *fd_p >= 0; /* Check if kernel seems to be too old to know SOCK_CLOEXEC */ - if (*fd_p < 0 && errno == EINVAL) + if (*fd_p < 0 && (errno == EINVAL || errno == EPROTOTYPE)) #endif { *fd_p = socket (domain, type, protocol); @@ -903,7 +903,7 @@ _dbus_connect_exec (const char *path, retval = socketpair(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0, fds); cloexec_done = retval >= 0; - if (retval < 0 && (errno == EINVAL)) + if (retval < 0 && (errno == EINVAL || errno == EPROTOTYPE)) #endif { retval = socketpair(AF_UNIX, SOCK_STREAM, 0, fds); @@ -3081,7 +3081,7 @@ _dbus_full_duplex_pipe (int *fd1, retval = socketpair(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0, fds); cloexec_done = retval >= 0; - if (retval < 0 && errno == EINVAL) + if (retval < 0 && (errno == EINVAL || errno == EPROTOTYPE)) #endif { retval = socketpair(AF_UNIX, SOCK_STREAM, 0, fds); -- 1.7.9.5