From: Bruno Haible <bruno@clisp.org>
To: Nicholas Gaya <nicholasgaya@gmail.com>
Cc: bug-gnulib@gnu.org
Subject: Re: Bug in test-fcntl.c
Date: Fri, 14 May 2021 23:53:46 +0200 [thread overview]
Message-ID: <2837621.H2iKm4OoCl@omega> (raw)
In-Reply-To: <115ECBAE-7C37-4BC1-A48B-94A0778AAE8E@gmail.com>
Nicholas Gaya wrote:
> The process hierarchy starts with tclsh (MacPorts), then a bunch of layers of make and sh (from oath-toolkit's recursive `make check`), and finally the test-fcntl executable. I was using MacPorts' "trace mode", which seems to be responsible for the particularly high number of inherited open files, but without trace mode I still run into the issue; the returned fd is 11 in this case.
Thanks; that gives a hint also who is eating up the file descriptors 3 to 10.
> But I don't really want to focus on my specific use-case (for which I already have a workaround). I think the patch is warranted just on the basis that it makes the test a bit more robust, with minimal drawbacks.
Yes. But I wanted to have a description of the cause, that I can include in
comments.
Done. Thanks for the report!
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.
diff --git a/tests/test-execute-main.c b/tests/test-execute-main.c
index a6a9fe4..372ff1d 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 caf629d..cb834b4 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__
prev parent reply other threads:[~2021-05-14 21:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-08 23:10 Bug in test-fcntl.c Nicholas Gaya
2021-05-09 2:03 ` Bruno Haible
2021-05-09 3:27 ` Nicholas Gaya
2021-05-09 12:24 ` Bruno Haible
2021-05-11 3:25 ` Nicholas Gaya
2021-05-14 21:53 ` Bruno Haible [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2837621.H2iKm4OoCl@omega \
--to=bruno@clisp.org \
--cc=bug-gnulib@gnu.org \
--cc=nicholasgaya@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).