ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/process_stats.c
(Generate patch)

Comparing projects/libstatgrab/src/libstatgrab/process_stats.c (file contents):
Revision 1.61 by ats, Wed Apr 7 10:33:50 2004 UTC vs.
Revision 1.62 by pajs, Wed Apr 7 14:45:33 2004 UTC

# Line 213 | Line 213 | sg_process_stats *sg_get_process_stats(int *entries){
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);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines