aboutsummaryrefslogtreecommitdiff
path: root/posix/bug-getopt4.c
diff options
context:
space:
mode:
Diffstat (limited to 'posix/bug-getopt4.c')
-rw-r--r--posix/bug-getopt4.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/posix/bug-getopt4.c b/posix/bug-getopt4.c
index 0956ca5..c5e3c14 100644
--- a/posix/bug-getopt4.c
+++ b/posix/bug-getopt4.c
@@ -2,6 +2,7 @@
#include <getopt.h>
#include <unistd.h>
#include <stdio.h>
+#include <stdlib.h>
static const struct option opts[] =
{
@@ -52,12 +53,14 @@ one_test (const char *fmt, int argc, char *argv[], int n, int expected[n])
static int
do_test (void)
{
- char *fname = tmpnam (NULL);
- if (fname == NULL)
+ char fname[] = "/tmp/bug-getopt4.XXXXXX";
+ int fd = mkstemp (fname);
+ if (fd == -1)
{
- puts ("cannot generate name for temporary file");
+ printf ("mkstemp failed: %m\n");
return 1;
}
+ close (fd);
if (freopen (fname, "w+", stderr) == NULL)
{