]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Use pipe in vgdb if system doesn't have pipe2
authorMark Wielaard <mark@klomp.org>
Sun, 16 Apr 2023 11:15:03 +0000 (13:15 +0200)
committerMark Wielaard <mark@klomp.org>
Sun, 16 Apr 2023 11:18:00 +0000 (13:18 +0200)
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

NEWS
configure.ac
coregrind/vgdb.c

diff --git a/NEWS b/NEWS
index a8ab817e17469d64b06ab4091fa9020500954133..6af3169d5a6cc953e77fd5feed4fd87fdeee8dd1 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -151,6 +151,7 @@ are not entered into bugzilla tend to get forgotten about or ignored.
 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
index 66437a8000da291d3f17a9530ae5ad46ea79223b..a886d0deaad4e5bc42eadfbc7ff834997d22261b 100755 (executable)
@@ -4820,6 +4820,7 @@ AC_CHECK_FUNCS([     \
         memset       \
         mkdir        \
         mremap       \
+        pipe2       \
         ppoll        \
         preadv       \
         preadv2      \
index c4a7042984800b369b8aec2a6b69270ba4a1e60a..7ed9a8b2e902a2d8a4b2a2bb85f81e7b7f275649 100644 (file)
@@ -1142,11 +1142,28 @@ int fork_and_exec_valgrind (int argc, char **argv, const char *working_dir,
    // 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) {