]> git.eshelyaron.com Git - emacs.git/commitdiff
* filelock.c (create_lock_file) [!HAVE_MKOSTEMP && !HAVE_MKSTEMP]:
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 14 Jul 2013 23:12:42 +0000 (16:12 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 14 Jul 2013 23:12:42 +0000 (16:12 -0700)
Simplify by making this case like the other two.  This is a bit
slower on obsolete hosts, but the extra complexity isn't worth it.

src/ChangeLog
src/filelock.c

index 6ee0cacb5209941f2dd33aa97c39b7f39fa38f57..329fa6ba67073c1faf452cb6c9ff7833338eb220 100644 (file)
@@ -1,5 +1,9 @@
 2013-07-14  Paul Eggert  <eggert@cs.ucla.edu>
 
+       * filelock.c (create_lock_file) [!HAVE_MKOSTEMP && !HAVE_MKSTEMP]:
+       Simplify by making this case like the other two.  This is a bit
+       slower on obsolete hosts, but the extra complexity isn't worth it.
+
        * callproc.c (child_setup, relocate_fd) [!DOS_NT]:
        * process.c (create_process) [!DOS_NT]:
        Remove now-unnecessary calls to emacs_close.
index 244663ad20aec46e9eb62a5d376b5fb9d7bfc1e3..4982dd3de130df25a7d6bd74b82f6c6b79ed9038 100644 (file)
@@ -412,8 +412,6 @@ create_lock_file (char *lfname, char *lock_info_str, bool force)
       USE_SAFE_ALLOCA;
       char *nonce = SAFE_ALLOCA (lfdirlen + sizeof nonce_base);
       int fd;
-      bool need_fchmod;
-      mode_t world_readable = S_IRUSR | S_IRGRP | S_IROTH;
       memcpy (nonce, lfname, lfdirlen);
       strcpy (nonce + lfdirlen, nonce_base);
 
@@ -421,17 +419,14 @@ create_lock_file (char *lfname, char *lock_info_str, bool force)
       /* 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);
-      need_fchmod = 1;
 #elif HAVE_MKSTEMP
       /* Prefer mkstemp to mktemp, as it avoids a race between
         mktemp and emacs_open.  */
       fd = mkstemp (nonce);
-      need_fchmod = 1;
 #else
       mktemp (nonce);
       fd = emacs_open (nonce, O_WRONLY | O_CREAT | O_EXCL | O_BINARY,
-                      world_readable);
-      need_fchmod = 0;
+                      S_IRUSR | S_IWUSR);
 #endif
 
       if (fd < 0)
@@ -445,7 +440,7 @@ create_lock_file (char *lfname, char *lock_info_str, bool force)
          lock_info_len = strlen (lock_info_str);
          err = 0;
          if (emacs_write (fd, lock_info_str, lock_info_len) != lock_info_len
-             || (need_fchmod && fchmod (fd, world_readable) != 0))
+             || fchmod (fd, S_IRUSR | S_IRGRP | S_IROTH) != 0)
            err = errno;
          /* There is no need to call fsync here, as the contents of
             the lock file need not survive system crashes.  */