]> sjero.net Git - wget/blobdiff - src/utils.c
[svn] Improve built-in memory debugger.
[wget] / src / utils.c
index 2319947a5ffb18675d7f8b044b8d8c98ff0b95d9..eace57c3431b64dcf10182c11c5c5df1e926aeb5 100644 (file)
@@ -558,6 +558,14 @@ fopen_excl (const char *fname, int binary)
     return NULL;
   return fdopen (fd, binary ? "wb" : "w");
 #else  /* not O_EXCL */
+  /* Manually check whether the file exists.  This is prone to race
+     conditions, but systems without O_EXCL haven't deserved
+     better.  */
+  if (file_exists_p (fname))
+    {
+      errno = EEXIST;
+      return NULL;
+    }
   return fopen (fname, binary ? "wb" : "w");
 #endif /* not O_EXCL */
 }