]> code.delx.au - gnu-emacs/blobdiff - src/filelock.c
Delete the code that was trying to define BSD "right"
[gnu-emacs] / src / filelock.c
index d30571a3598ea6bfe33baf13d342fd0396d527cf..69c4c40c011a9ae4f775f5f610329af9cf080ee6 100644 (file)
@@ -58,14 +58,14 @@ extern int errno;
    that's too unreliable.  Hence the separate file, which could
    theoretically be updated by daemons running separately -- but this
    whole idea is unimplemented; in practice, at least in our
-   environment, it seems such stale locks arise fiarly infrequently, and
+   environment, it seems such stale locks arise fairly infrequently, and
    Emacs' standard methods of dealing with clashes suffice.
 
    We use symlinks instead of normal files because (1) they can be
    stored more efficiently on the filesystem, since the kernel knows
    they will be small, and (2) all the info about the lock can be read
    in a single system call (readlink).  Although we could use regular
-   files to be useful on old systems lacking symlinks, noawdays
+   files to be useful on old systems lacking symlinks, nowadays
    virtually all such systems are probably single-user anyway, so it
    didn't seem worth the complication.
    
@@ -86,11 +86,12 @@ typedef struct
 {
   char *user;
   char *host;
-  int pid;
+  unsigned long pid;
 } lock_info_type;
 
-/* When we read the info back, we might need this much more.  */
-#define LOCK_PID_MAX 21 /* enough for signed 64 bits plus null */
+/* When we read the info back, we might need this much more,
+   enough for decimal representation plus null.  */
+#define LOCK_PID_MAX (4 * sizeof (unsigned long))
 
 /* Free the two dynamically-allocated pieces in PTR.  */
 #define FREE_LOCK_INFO(i) do { xfree ((i).user); xfree ((i).host); } while (0)
@@ -134,9 +135,11 @@ lock_file_1 (lfname, force)
   register int err;
   char *user_name = XSTRING (Fuser_login_name (Qnil))->data;
   char *host_name = XSTRING (Fsystem_name ())->data;
-  char *lock_info_str = alloca (strlen (user_name) + strlen (host_name) + 21);
+  char *lock_info_str = alloca (strlen (user_name) + strlen (host_name)
+                                + LOCK_PID_MAX + 5);
 
-  sprintf (lock_info_str, "%s@%s.%d", user_name, host_name, getpid ());
+  sprintf (lock_info_str, "%s@%s.%lu", user_name, host_name,
+           (unsigned long) getpid ());
 
   err = symlink (lock_info_str, lfname);
   if (errno == EEXIST && force)