-/* Copyright (C) 1991, 1992, 1996, 1998, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
This file is derived from mkstemp.c from the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
+#elif HAVE_TIME_H
+#include <time.h>
#endif
#include "ansidecl.h"
if (fd >= 0)
/* The file does not exist. */
return fd;
+ if (errno != EEXIST
+#ifdef EISDIR
+ && errno != EISDIR
+#endif
+ )
+ /* Fatal error (EPERM, ENOSPC etc). Doesn't make sense to loop. */
+ break;
/* This is a random value. It is only necessary that the next
TMP_MAX values generated by adding 7777 to VALUE are different