Add a configure check for pipe2. If it isn't available use pipe
and fcntl F_SETFD FD_CLOEXEC in vgdb.c.
https://bugs.kde.org/show_bug.cgi?id=468556
467714 fdleak_* and rlimit tests fail when parent process has more than
64 descriptors opened
467839 Gdbserver: Improve compatibility of library directory name
+468556 Build failure for vgdb
n-i-bz FreeBSD rfork syscall fail with EINVAL or ENOSYS rather than VG_(unimplemented)
To see details of a given bug, visit
memset \
mkdir \
mremap \
+ pipe2 \
ppoll \
preadv \
preadv2 \
// We will use a pipe to track what the child does,
// so we can report failure.
int pipefd[2];
+#ifdef HAVE_PIPE2
if (pipe2 (pipefd, O_CLOEXEC) == -1) {
err = errno;
perror ("pipe2 failed");
return err;
}
+#else
+ if (pipe (pipefd) == -1) {
+ err = errno;
+ perror ("pipe failed");
+ return err;
+ } else {
+ if (fcntl (pipefd[0], F_SETFD, FD_CLOEXEC) == -1
+ || fcntl (pipefd[1], F_SETFD, FD_CLOEXEC) == -1) {
+ err = errno;
+ perror ("fcntl failed");
+ close (pipefd[0]);
+ close (pipefd[1]);
+ return err;
+ }
+ }
+#endif
pid_t p = fork ();
if (p < 0) {