This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] Fix stdlib/test-canon.c to reliably run over NFS
- From: Adam Nemet <anemet at caviumnetworks dot com>
- To: libc-alpha at sources dot redhat dot com
- Date: Thu, 20 Jul 2006 17:49:14 -0700
- Subject: [PATCH] Fix stdlib/test-canon.c to reliably run over NFS
On NFS unlinking a still open file will rename it to .nfsXXX. This
test does just that and then tries to remove the directory that is
supposed to be empty. This fails so the test never cleans up after
itself. If you happen to run the same test later (after a proper
tests-clean) it is unprepared to deal with the already-existing
directory and fails in an unexpected way.
This patch closes the fd before unlinking the file.
2006-07-20 Adam Nemet <anemet@caviumnetworks.com>
* stdlib/test-canon.c (do_test): Close fd before unlinking.
Index: stdlib/test-canon.c
===================================================================
RCS file: /cvs/glibc/libc/stdlib/test-canon.c,v
retrieving revision 1.15
diff -F^\([(a-zA-Z0-9_]\|#define\) -u -p -u -p -r1.15 test-canon.c
--- stdlib/test-canon.c 27 Apr 2005 07:32:32 -0000 1.15
+++ stdlib/test-canon.c 21 Jul 2006 00:34:49 -0000
@@ -213,7 +213,10 @@ do_test (int argc, char ** argv)
}
if (fd >= 0)
- unlink ("doesExist/someFile");
+ {
+ close (fd);
+ unlink ("doesExist/someFile");
+ }
if (has_dir)
rmdir ("doesExist");