diff options
Diffstat (limited to 'posix/bug-getopt3.c')
-rw-r--r-- | posix/bug-getopt3.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/posix/bug-getopt3.c b/posix/bug-getopt3.c index c3a8cb2..45a8d3e 100644 --- a/posix/bug-getopt3.c +++ b/posix/bug-getopt3.c @@ -2,6 +2,7 @@ #include <getopt.h> #include <unistd.h> #include <stdio.h> +#include <stdlib.h> static const struct option opts[] = { @@ -48,12 +49,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-getopt3.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) { |