[PATCH 2/2] openat2-tests: port to NFS

Paul Eggert <[email protected]>
Newsgroups gmane.comp.lib.gnulib.bugs
Message-ID <[email protected]>
* tests/test-openat2.c (do_test_basic): Close fd before
removing its file.  This fixes a file descriptor leak,
and ports the test to NFS, where removing an unclosed
file leaves behind a .nfs* file that prevents the
parent directory from being removed.
---
 ChangeLog            | 9 +++++++++
 tests/test-openat2.c | 1 +
 2 files changed, 10 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 025f560095..bc891e3581 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2026-06-19  Paul Eggert  <[email protected]>
+
+	openat2-tests: port to NFS
+	* tests/test-openat2.c (do_test_basic): Close fd before
+	removing its file.  This fixes a file descriptor leak,
+	and ports the test to NFS, where removing an unclosed
+	file leaves behind a .nfs* file that prevents the
+	parent directory from being removed.
+
 2026-06-18  Paul Eggert  <[email protected]>
 
 	openat2: fix typo for circa-2012 Linux
diff --git a/tests/test-openat2.c b/tests/test-openat2.c
index cde9576fbd..b53d9db651 100644
--- a/tests/test-openat2.c
+++ b/tests/test-openat2.c
@@ -560,6 +560,7 @@ do_test_basic ()
     ASSERT (fd2 == -1);
   }
 
+  ASSERT (close (fd) == 0);
   ASSERT (unlinkat (dfd, "some-file", 0) == 0);
 
   ASSERT (unlinkat (dfd, "dirlink", 0) == 0);
-- 
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.