1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/patches/glibc/ports-2.13/260-assume-pipe2.patch Sun Jul 17 15:48:27 2011 +0200
1.3 @@ -0,0 +1,40 @@
1.4 +http://bugs.gentoo.org/250342
1.5 +http://sources.redhat.com/bugzilla/show_bug.cgi?id=9685
1.6 +
1.7 +we cant assume sock_cloexec and pipe2 are bound together as the former defines
1.8 +are found in glibc only while the latter are a combo of kernel headers and
1.9 +glibc. so if we do a runtime detection of SOCK_CLOEXEC, but pipe2() is a stub
1.10 +inside of glibc, we hit a problem. for example:
1.11 +
1.12 +#include <grp.h>
1.13 +#include <stdio.h>
1.14 +main()
1.15 +{
1.16 + getgrnam("portage");
1.17 + if (!popen("ls", "r"))
1.18 + perror("popen()");
1.19 +}
1.20 +
1.21 +getgrnam() will detect that the kernel supports SOCK_CLOEXEC and then set both
1.22 +__have_sock_cloexec and __have_pipe2 to true. but if glibc was built against
1.23 +older kernel headers where __NR_pipe2 does not exist, glibc will have a ENOSYS
1.24 +stub for it. so popen() will always fail as glibc assumes pipe2() works.
1.25 +
1.26 +diff -durN glibc-2.13.orig/socket/have_sock_cloexec.c glibc-2.13/socket/have_sock_cloexec.c
1.27 +--- glibc-2.13.orig/socket/have_sock_cloexec.c 2008-07-25 18:46:23.000000000 +0200
1.28 ++++ glibc-2.13/socket/have_sock_cloexec.c 2009-11-13 00:50:15.000000000 +0100
1.29 +@@ -16,9 +16,14 @@
1.30 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1.31 + 02111-1307 USA. */
1.32 +
1.33 ++#include <fcntl.h>
1.34 + #include <sys/socket.h>
1.35 + #include <kernel-features.h>
1.36 +
1.37 + #if defined SOCK_CLOEXEC && !defined __ASSUME_SOCK_CLOEXEC
1.38 + int __have_sock_cloexec;
1.39 + #endif
1.40 ++
1.41 ++#if defined O_CLOEXEC && !defined __ASSUME_PIPE2
1.42 ++int __have_pipe2;
1.43 ++#endif