213 |
|
|
214 |
|
/* cpu */ |
215 |
|
proc_state_ptr->cpu_percent = (100.0 * (utime + stime)) / ((uptime * 100.0) - starttime); |
216 |
– |
printf("%s ut: %lu st: %lu up: %lu start: %lu\n", proc_state_ptr->process_name, utime, stime, uptime , starttime); |
216 |
|
|
217 |
|
fclose(f); |
218 |
+ |
|
219 |
+ |
/* uid / gid */ |
220 |
+ |
snprintf(filename, MAX_FILE_LENGTH, "/proc/%s/status", dir_entry->d_name); |
221 |
+ |
if ((f=fopen(filename, "r")) == NULL) { |
222 |
+ |
/* Open failed.. Process since vanished, or the path was too long. |
223 |
+ |
* Ah well, move onwards to the next one */ |
224 |
+ |
continue; |
225 |
+ |
} |
226 |
+ |
|
227 |
+ |
if((ptr=sg_f_read_line(f, "Uid:"))==NULL){ |
228 |
+ |
fclose(f); |
229 |
+ |
continue; |
230 |
+ |
} |
231 |
+ |
sscanf(ptr, "Uid:\t%d\t%d\t%*d\t%*d\n", &(proc_state_ptr->uid), &(proc_state_ptr->euid)); |
232 |
+ |
|
233 |
+ |
if((ptr=sg_f_read_line(f, "Gid:"))==NULL){ |
234 |
+ |
fclose(f); |
235 |
+ |
continue; |
236 |
+ |
} |
237 |
+ |
sscanf(ptr, "Gid:\t%d\t%d\t%*d\t%*d\n", &(proc_state_ptr->gid), &(proc_state_ptr->egid)); |
238 |
+ |
|
239 |
+ |
fclose(f); |
240 |
|
|
241 |
|
/* proctitle */ |
242 |
|
snprintf(filename, MAX_FILE_LENGTH, "/proc/%s/cmdline", dir_entry->d_name); |