aboutsummaryrefslogtreecommitdiffstats
path: root/src/filelock.c
diff options
context:
space:
mode:
authorRichard M. Stallman1998-05-18 00:17:38 +0000
committerRichard M. Stallman1998-05-18 00:17:38 +0000
commitc321b1908be8c325f9a0a80a583dbb73b2399871 (patch)
treeb9d5c339ff56c933382165a1b2384645131f35ed /src/filelock.c
parentc519f68fa90c4a9a138e2e4c4d697ac1145bdd75 (diff)
downloademacs-c321b1908be8c325f9a0a80a583dbb73b2399871.tar.gz
emacs-c321b1908be8c325f9a0a80a583dbb73b2399871.zip
(get_boot_time): Scan the whole wtmp file
to find the most recent reboot.
Diffstat (limited to 'src/filelock.c')
-rw-r--r--src/filelock.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/filelock.c b/src/filelock.c
index 819516d04bd..6876cbdb5c1 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -104,13 +104,27 @@ get_boot_time ()
104 return boot_time; 104 return boot_time;
105 105
106 utmpname ("/var/log/wtmp"); 106 utmpname ("/var/log/wtmp");
107 ut.ut_type = BOOT_TIME; 107 setutent ();
108 utp = getutid (&ut); 108 boot_time = 1;
109 while (1)
110 {
111 /* Find the next reboot record. */
112 ut.ut_type = BOOT_TIME;
113 utp = getutid (&ut);
114 if (! utp)
115 break;
116 /* Compare reboot times and use the newest one. */
117 if (utp->ut_time > boot_time)
118 boot_time = utp->ut_time;
119 /* Advance on element in the file
120 so that getutid won't repeat the same one. */
121 utp = getutent ();
122 if (! utp)
123 break;
124 }
109 endutent (); 125 endutent ();
110 126
111 if (!utp) 127 return boot_time;
112 return boot_time = 1;
113 return boot_time = utp->ut_time;
114#else 128#else
115 return 0; 129 return 0;
116#endif 130#endif