changeset 97371:23de3091fdd0

(process_times): Fix the case of System process.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 09 Aug 2008 18:19:28 +0000
parents 758f38fd4cba
children aeb822613377
files src/w32.c
diffstat 1 files changed, 16 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/w32.c	Sat Aug 09 17:56:14 2008 +0000
+++ b/src/w32.c	Sat Aug 09 18:19:28 2008 +0000
@@ -3608,16 +3608,29 @@
   utime_usec = fmodl (tem2, 1000000.0L);
   utime_sec = tem2 * 0.000001L;
   *utime = ltime (utime_sec, utime_usec);
-  tem = (convert_time_raw (ft_creation) - utc_base) * 0.1L;
+  tem = convert_time_raw (ft_creation);
+  /* Process no 4 (System) returns zero creation time.  */
+  if (tem)
+    tem = (tem - utc_base) * 0.1;
   ctime_usec = fmodl (tem, 1000000.0L);
   ctime_sec = tem * 0.000001L;
   *ctime = ltime (ctime_sec, ctime_usec);
-  tem = (convert_time_raw (ft_current) - utc_base) * 0.1L - tem;
+  if (tem)
+    tem = (convert_time_raw (ft_current) - utc_base) * 0.1L - tem;
   etime_usec = fmodl (tem, 1000000.0L);
   etime_sec = tem * 0.000001L;
   *etime = ltime (etime_sec, etime_usec);
 
-  *pcpu = 100.0 * (tem1 + tem2) / tem;
+  if (tem)
+    {
+      *pcpu = 100.0 * (tem1 + tem2) / tem;
+      if (*pcpu > 100)
+	*pcpu = 100.0;
+    }
+  else
+    *pcpu = 0;
+
+  return 1;
 }
 
 Lisp_Object