The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 09-09-2008
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
  
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,886
Something like this works with most unix'es and Linux that have /proc:


Code:
DIR *procfs;
struct dirent *entry;
procfs = opendir("/proc");
while ( entry = readdir(procfs) ) {
 if (!isdigit(entry->d_name[0])) continue;
 /* process id is in d_name. Open the file /proc/d_name/stat */
}