From 093778cab5f8202b547d9c778228ea7eb8177b6c Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 14 May 2021 23:50:52 +0200 Subject: [PATCH] fcntl tests: Avoid failure in MacPorts. Reported by Nicholas Gaya in . * tests/test-fcntl.c (main): Close fd 10 before assuming that it is closed. * tests/test-execute-main.c: Update comment. --- ChangeLog | 9 +++++++++ tests/test-execute-main.c | 3 ++- tests/test-fcntl.c | 10 ++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 592b4c41b0..e3f1d8220a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2021-05-14 Bruno Haible + + fcntl tests: Avoid failure in MacPorts. + Reported by Nicholas Gaya in + . + * 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 linked-list-unportable-test: New module. diff --git a/tests/test-execute-main.c b/tests/test-execute-main.c index a6a9fe4069..372ff1d4b5 100644 --- a/tests/test-execute-main.c +++ b/tests/test-execute-main.c @@ -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) diff --git a/tests/test-fcntl.c b/tests/test-fcntl.c index caf629dabb..cb834b4be1 100644 --- a/tests/test-fcntl.c +++ b/tests/test-fcntl.c @@ -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__ -- 2.39.5