From bd26d5a361621e6b921cb37691395bc0efb10797 Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Thu, 19 Mar 1998 21:19:07 +0000 Subject: [PATCH] (get_boot_time): Conditionalize on BOOT_TIME. (lock_file_1): Add boot-time to lock only if available. --- src/filelock.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/filelock.c b/src/filelock.c index 2bb86bad337..116f96eacd1 100644 --- a/src/filelock.c +++ b/src/filelock.c @@ -89,6 +89,7 @@ static time_t boot_time; static time_t get_boot_time () { +#ifdef BOOT_TIME struct utmp ut, *utp; if (boot_time) @@ -102,6 +103,9 @@ get_boot_time () 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 @@ lock_file_1 (lfname, force) int force; { register int err; + time_t boot_time; char *user_name; char *host_name; char *lock_info_str; @@ -173,8 +178,13 @@ lock_file_1 (lfname, force) 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) -- 2.39.5