From: Eli Zaretskii Date: Sat, 9 Aug 2008 18:19:28 +0000 (+0000) Subject: (process_times): Fix the case of System process. X-Git-Tag: emacs-pretest-23.0.90~3569 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3af03101a78a582ce3b788b56009323a95638b83;p=emacs.git (process_times): Fix the case of System process. --- diff --git a/src/w32.c b/src/w32.c index 6bbeb8e092f..1d3c5182912 100644 --- a/src/w32.c +++ b/src/w32.c @@ -3608,16 +3608,29 @@ process_times (h_proc, ctime, etime, stime, utime, pcpu) 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