# | Line 143 | Line 143 | sg_process_stats *sg_get_process_stats(int *entries){ | |
---|---|---|
143 | int len; | |
144 | int rc; | |
145 | time_t uptime; | |
146 | + | long tickspersec; |
147 | #endif | |
148 | ||
149 | #ifdef LINUX | |
# | Line 255 | Line 256 | sg_process_stats *sg_get_process_stats(int *entries){ | |
256 | ||
257 | /* cpu */ | |
258 | proc_state_ptr->cpu_percent = (100.0 * (utime + stime)) / ((uptime * 100.0) - starttime); | |
259 | + | tickspersec = sysconf (_SC_CLK_TCK); |
260 | + | if (tickspersec < 0) { |
261 | + | proc_state_ptr->time_spent = 0; |
262 | + | } |
263 | + | else { |
264 | + | proc_state_ptr->time_spent = (utime + stime) / tickspersec; |
265 | + | } |
266 | ||
267 | fclose(f); | |
268 |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |