Fix some minor races in hosts lacking mkostemp.
[bpt/emacs.git] / src / filelock.c
index b9c991e..0f31b7d 100644 (file)
@@ -411,28 +411,14 @@ create_lock_file (char *lfname, char *lock_info_str, bool force)
       memcpy (nonce, lfname, lfdirlen);
       strcpy (nonce + lfdirlen, nonce_base);
 
-#if HAVE_MKOSTEMP
-      /* Prefer mkostemp to mkstemp, as it avoids a window where FD is
-        temporarily open without close-on-exec.  */
       fd = mkostemp (nonce, O_BINARY | O_CLOEXEC);
-#elif HAVE_MKSTEMP
-      /* Prefer mkstemp to mktemp, as it avoids a race between
-        mktemp and emacs_open.  */
-      fd = mkstemp (nonce);
-#else
-      mktemp (nonce);
-      fd = emacs_open (nonce, O_WRONLY | O_CREAT | O_EXCL | O_BINARY,
-                      S_IRUSR | S_IWUSR);
-#endif
-
       if (fd < 0)
        err = errno;
       else
        {
          ptrdiff_t lock_info_len;
-#if ! (HAVE_MKOSTEMP && O_CLOEXEC)
-         fcntl (fd, F_SETFD, FD_CLOEXEC);
-#endif
+         if (! O_CLOEXEC)
+           fcntl (fd, F_SETFD, FD_CLOEXEC);
          lock_info_len = strlen (lock_info_str);
          err = 0;
          /* Use 'write', not 'emacs_write', as garbage collection