--- emacs-20.7/src/filelock.c Tue May 16 04:02:19 2000 +++ emacs/src/filelock.c Tue Dec 5 01:34:56 2000 @@ -58,6 +58,10 @@ extern int errno; #endif +#ifdef HAVE_SETLOCALE +#include +#endif + /* The directory for writing temporary files. */ Lisp_Object Vtemporary_file_directory; @@ -75,6 +79,10 @@ #ifndef WTMP_FILE #define WTMP_FILE "/var/log/wtmp" #endif + +#ifndef PROC_UPTIME +# define PROC_UPTIME "/proc/uptime" +#endif /* The strategy: to lock a file FN, create a symlink .#FN in FN's directory, with link data `user@host.pid'. This avoids a single @@ -123,10 +131,30 @@ get_boot_time () { int counter; + FILE *proc_uptime; if (boot_time_initialized) return boot_time; boot_time_initialized = 1; + + if ((proc_uptime = fopen(PROC_UPTIME, "r")) != NULL) + { /* copied from Kaveh Ghazi's sh-utils-2.0/src/uptime.c. */ + double upsecs; + int result; + +#ifdef HAVE_SETLOCALE + setlocale(LC_NUMERIC, "C"); +#endif + fscanf(proc_uptime, "%lf", &upsecs); +#ifdef HAVE_SETLOCALE + setlocale(LC_NUMERIC, ""); +#endif + + fclose(proc_uptime); + if (result == 1) + return time(0) + (int) upsecs; + } + #if defined (CTL_KERN) && defined (KERN_BOOTTIME) {