Bug 497723 - forgot to restore callgrind output cleanup
[valgrind.git] / none / tests / file_dclose.c
blobb3f864ef99b08654dd6357fbb5a8821f2666fd30
1 #define _GNU_SOURCE
2 #include <unistd.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <fcntl.h>
6 #include "fdleak.h"
8 static int
9 openfile (const char *f)
11 return creat (f, O_RDWR);
14 static void
15 closefile (const char *f, int fd)
17 close (fd);
18 unlink (f);
21 int main ()
23 CLOSE_INHERITED_FDS;
25 const char *TMPFILE = "file_dclose.tmp";
26 int fd;
28 fd = openfile (TMPFILE);
29 if (fd != -1) {
30 fprintf(stderr, "close %d\n", fd);
31 close (fd);
34 fprintf (stderr, "time passes and we close %d again\n", fd);
35 closefile (TMPFILE, fd);
37 return 0;