diff options
author | Richard M. Stallman <rms@gnu.org> | 1998-05-18 00:17:38 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1998-05-18 00:17:38 +0000 |
commit | c321b1908be8c325f9a0a80a583dbb73b2399871 (patch) | |
tree | b9d5c339ff56c933382165a1b2384645131f35ed /src/filelock.c | |
parent | c519f68fa90c4a9a138e2e4c4d697ac1145bdd75 (diff) | |
download | emacs-c321b1908be8c325f9a0a80a583dbb73b2399871.tar.gz |
(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.c | 24 |
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 () return boot_time; utmpname ("/var/log/wtmp"); - ut.ut_type = BOOT_TIME; - utp = getutid (&ut); + setutent (); + boot_time = 1; + while (1) + { + /* Find the next reboot record. */ + ut.ut_type = BOOT_TIME; + utp = getutid (&ut); + if (! utp) + break; + /* Compare reboot times and use the newest one. */ + if (utp->ut_time > boot_time) + boot_time = utp->ut_time; + /* Advance on element in the file + so that getutid won't repeat the same one. */ + utp = getutent (); + if (! utp) + break; + } endutent (); - if (!utp) - return boot_time = 1; - return boot_time = utp->ut_time; + return boot_time; #else return 0; #endif |