aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1998-03-19 21:19:07 +0000
committerRichard M. Stallman1998-03-19 21:19:07 +0000
commitbd26d5a361621e6b921cb37691395bc0efb10797 (patch)
tree2f897742d64826b71fe69985b0e63f9c56f7af30 /src
parent5a8dd30e2630d75ada97b2fb5df34d889693f11d (diff)
downloademacs-bd26d5a361621e6b921cb37691395bc0efb10797.tar.gz
emacs-bd26d5a361621e6b921cb37691395bc0efb10797.zip
(get_boot_time): Conditionalize on BOOT_TIME.
(lock_file_1): Add boot-time to lock only if available.
Diffstat (limited to 'src')
-rw-r--r--src/filelock.c14
1 files 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;
89static time_t 89static time_t
90get_boot_time () 90get_boot_time ()
91{ 91{
92#ifdef BOOT_TIME
92 struct utmp ut, *utp; 93 struct utmp ut, *utp;
93 94
94 if (boot_time) 95 if (boot_time)
@@ -102,6 +103,9 @@ get_boot_time ()
102 if (!utp) 103 if (!utp)
103 return boot_time = 1; 104 return boot_time = 1;
104 return boot_time = utp->ut_time; 105 return boot_time = utp->ut_time;
106#else
107 return 0;
108#endif;
105} 109}
106 110
107/* Here is the structure that stores information about a lock. */ 111/* Here is the structure that stores information about a lock. */
@@ -158,6 +162,7 @@ lock_file_1 (lfname, force)
158 int force; 162 int force;
159{ 163{
160 register int err; 164 register int err;
165 time_t boot_time;
161 char *user_name; 166 char *user_name;
162 char *host_name; 167 char *host_name;
163 char *lock_info_str; 168 char *lock_info_str;
@@ -173,8 +178,13 @@ lock_file_1 (lfname, force)
173 lock_info_str = (char *)alloca (strlen (user_name) + strlen (host_name) 178 lock_info_str = (char *)alloca (strlen (user_name) + strlen (host_name)
174 + LOCK_PID_MAX + 5); 179 + LOCK_PID_MAX + 5);
175 180
176 sprintf (lock_info_str, "%s@%s.%lu:%lu", user_name, host_name, 181 boot_time = get_boot_time ();
177 (unsigned long) getpid (), (unsigned long) get_boot_time ()); 182 if (boot_time)
183 sprintf (lock_info_str, "%s@%s.%lu:%lu", user_name, host_name,
184 (unsigned long) getpid (), (unsigned long) boot_time);
185 else
186 sprintf (lock_info_str, "%s@%s.%lu", user_name, host_name,
187 (unsigned long) getpid ());
178 188
179 err = symlink (lock_info_str, lfname); 189 err = symlink (lock_info_str, lfname);
180 if (errno == EEXIST && force) 190 if (errno == EEXIST && force)