]> Savannah Git Hosting - gnulib.git/commitdiff
fcntl tests: Avoid failure in MacPorts.
authorBruno Haible <bruno@clisp.org>
Fri, 14 May 2021 21:50:52 +0000 (23:50 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 14 May 2021 21:50:52 +0000 (23:50 +0200)
Reported by Nicholas Gaya <nicholasgaya@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2021-05/msg00014.html>.

* tests/test-fcntl.c (main): Close fd 10 before assuming that it is
closed.
* tests/test-execute-main.c: Update comment.

ChangeLog
tests/test-execute-main.c
tests/test-fcntl.c

index 592b4c41b00129572f962e0d2dd8c48deffa50f8..e3f1d8220a5cbf84795b26b144276e8078217f2f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2021-05-14  Bruno Haible  <bruno@clisp.org>
+
+       fcntl tests: Avoid failure in MacPorts.
+       Reported by Nicholas Gaya <nicholasgaya@gmail.com> in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2021-05/msg00014.html>.
+       * tests/test-fcntl.c (main): Close fd 10 before assuming that it is
+       closed.
+       * tests/test-execute-main.c: Update comment.
+
 2021-05-14  Bruno Haible  <bruno@clisp.org>
 
        linked-list-unportable-test: New module.
index a6a9fe4069d9ddee8e6beee98bda6df462e8f48a..372ff1d4b5c8359bddec16d0e577df6902d5584e 100644 (file)
@@ -69,7 +69,8 @@ main (int argc, char *argv[])
          Such file descriptors have been seen:
            - with GNU make, when invoked as 'make -j N' with j > 1,
            - in some versions of the KDE desktop environment,
-           - on NetBSD.
+           - on NetBSD,
+           - in MacPorts with the "trace mode" enabled.
        */
       #if HAVE_CLOSE_RANGE
       if (close_range (3, 20 - 1, 0) < 0)
index caf629dabba723b7769d4b699ff51b3d1587d7ce..cb834b4be17f2100e1a7d0a554f407cf89dd53fd 100644 (file)
@@ -415,6 +415,16 @@ main (int argc, char *argv[])
   ASSERT (close (fd) == 0);
   ASSERT (unlink (file) == 0);
 
+  /* Close file descriptors that may have been inherited from the parent
+     process and that would cause failures below.
+     Such file descriptors have been seen:
+       - with GNU make, when invoked as 'make -j N' with j > 1,
+       - in some versions of the KDE desktop environment,
+       - on NetBSD,
+       - in MacPorts with the "trace mode" enabled.
+   */
+  (void) close (10);
+
   /* Test whether F_DUPFD_CLOEXEC is effective.  */
   ASSERT (fcntl (1, F_DUPFD_CLOEXEC, 10) >= 0);
 #if defined _WIN32 && !defined __CYGWIN__