mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-22 21:10:07 +00:00
a277af22ea
We can't assume sock_cloexec and pipe2 are bound together as the former defines are found in glibc only while the latter are a combo of kernel headers and glibc. So if we do a runtime detection of SOCK_CLOEXEC, but pipe2() is a stub inside of glibc, we hit a problem. For example: main() { getgrnam("portage"); if (!popen("ls", "r")) perror("popen()"); } getgrnam() will detect that the kernel supports SOCK_CLOEXEC and then set both __have_sock_cloexec and __have_pipe2 to true. But if glibc was built against older kernel headers where __NR_pipe2 does not exist, glibc will have a ENOSYS stub for it. So popen() will always fail as glibc assumes pipe2() works. While this isn't too much of an issue for some arches as they added the functionality to the kernel at the same time, not all arches are that lucky. Since the code already has dedicated names for each feature, delete the defines wiring these three features together and make each one a proper dedicated knob. We've been carrying this in Gentoo since glibc-2.9. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
33 lines
1.1 KiB
C
33 lines
1.1 KiB
C
/* Copyright (C) 2008-2012 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library; if not, see
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
#include <fcntl.h>
|
|
#include <sys/socket.h>
|
|
#include <kernel-features.h>
|
|
|
|
#if defined SOCK_CLOEXEC && !defined __ASSUME_SOCK_CLOEXEC
|
|
int __have_sock_cloexec;
|
|
#endif
|
|
|
|
#if defined O_CLOEXEC && !defined __ASSUME_PIPE2
|
|
int __have_pipe2;
|
|
#endif
|
|
|
|
#if defined O_CLOEXEC && !defined __ASSUME_DUP3
|
|
int __have_dup3;
|
|
#endif
|