changeset 21223:7f00d0edbd29

(get_boot_time): Conditionalize on BOOT_TIME. (lock_file_1): Add boot-time to lock only if available.
author Richard M. Stallman <rms@gnu.org>
date Thu, 19 Mar 1998 21:19:07 +0000
parents 4824e5e6d88a
children 1581abe1a67e
files src/filelock.c
diffstat 1 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/filelock.c	Thu Mar 19 10:30:55 1998 +0000
+++ b/src/filelock.c	Thu Mar 19 21:19:07 1998 +0000
@@ -89,6 +89,7 @@
 static time_t
 get_boot_time ()
 {
+#ifdef BOOT_TIME
   struct utmp ut, *utp;
 
   if (boot_time)
@@ -102,6 +103,9 @@
   if (!utp)
     return boot_time = 1;
   return boot_time = utp->ut_time;
+#else
+  return 0;
+#endif;
 }
 
 /* Here is the structure that stores information about a lock.  */
@@ -158,6 +162,7 @@
      int force;
 {
   register int err;
+  time_t boot_time;
   char *user_name;
   char *host_name;
   char *lock_info_str;
@@ -173,8 +178,13 @@
   lock_info_str = (char *)alloca (strlen (user_name) + strlen (host_name)
 				  + LOCK_PID_MAX + 5);
 
-  sprintf (lock_info_str, "%s@%s.%lu:%lu", user_name, host_name,
-           (unsigned long) getpid (), (unsigned long) get_boot_time ());
+  boot_time = get_boot_time ();
+  if (boot_time)
+    sprintf (lock_info_str, "%s@%s.%lu:%lu", user_name, host_name,
+	     (unsigned long) getpid (), (unsigned long) boot_time);
+  else
+    sprintf (lock_info_str, "%s@%s.%lu", user_name, host_name,
+	     (unsigned long) getpid ());    
 
   err = symlink (lock_info_str, lfname);
   if (errno == EEXIST && force)