summaryrefslogtreecommitdiffstats
path: root/tests/newfile.c
diff options
context:
space:
mode:
authorUlf Hermann <[email protected]>2017-04-11 16:31:27 +0200
committerUlf Hermann <[email protected]>2017-05-08 09:47:06 +0000
commit14192f5767b3388d9f6a1cdc8cadfb047b7a1f6a (patch)
treedfe8fa844fb85a22f7d9d4e09f3a1d8e2e8103bc /tests/newfile.c
parent9f59b055f56ccebaa3d272d153c74fb889958a8a (diff)
Close files before renaming or unlinking them
On windows we cannot rename or unlink open files. Change-Id: Ieae8712266a3e65217580d4936219767c5f26f21 Reviewed-by: Christian Kandeler <[email protected]>
Diffstat (limited to 'tests/newfile.c')
-rw-r--r--tests/newfile.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/tests/newfile.c b/tests/newfile.c
index 5eabdcb7..a2793171 100644
--- a/tests/newfile.c
+++ b/tests/newfile.c
@@ -63,8 +63,6 @@ main (int argc, char *argv[] __attribute__ ((unused)))
printf ("cannot create temporary file: %m\n");
exit (1);
}
- /* Remove the file when we exit. */
- unlink (fname);
elf_version (EV_CURRENT);
elf = elf_begin (fd, ELF_C_WRITE, NULL);
@@ -166,5 +164,10 @@ main (int argc, char *argv[] __attribute__ ((unused)))
(void) elf_end (elf);
}
+ close (fd);
+
+ /* Remove the file when we exit. */
+ unlink (fname);
+
return result;
}