aboutsummaryrefslogtreecommitdiff
path: root/stdio-common/tst-fdopen.c
diff options
context:
space:
mode:
Diffstat (limited to 'stdio-common/tst-fdopen.c')
-rw-r--r--stdio-common/tst-fdopen.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/stdio-common/tst-fdopen.c b/stdio-common/tst-fdopen.c
index e70a0cd6a5..136fff5858 100644
--- a/stdio-common/tst-fdopen.c
+++ b/stdio-common/tst-fdopen.c
@@ -1,6 +1,7 @@
/* Test for fdopen bugs. */
#include <stdio.h>
+#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
@@ -18,12 +19,18 @@ char buffer[256];
int
main (int argc, char *argv[])
{
- char *name;
+ char name[] = "/tmp/tst-fdopen.XXXXXX";
FILE *fp = NULL;
int retval = 0;
int fd;
- name = tmpnam (NULL);
+ fd = mkstemp (name);
+ if (fd == -1)
+ {
+ printf ("mkstemp failed: %m\n");
+ return 1;
+ }
+ close (fd);
fp = fopen (name, "w");
assert (fp != NULL)
fputs ("foobar and baz", fp);