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 -->
  #1 (permalink)  
Old 09-04-2008
gyula gyula is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 3
Thumbs down enumerate processes

Again for windows I can enumerate processes using toolhelp library


Code:
PROCESSENTRY32  pe32 = {0};
    HANDLE           hsp = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );

    pe32.dwSize = sizeof( PROCESSENTRY32 );
    Process32First( hsp, &pe32 );
    do
    {
         // access   PROCESSENTRY32 values
        /*
        DWORD   dwSize;
        DWORD   cntUsage;
        DWORD   th32ProcessID;          // this process
        ULONG_PTR th32DefaultHeapID;
        DWORD   th32ModuleID;           // associated exe
        DWORD   cntThreads;
        DWORD   th32ParentProcessID;    // this process's parent process
        LONG    pcPriClassBase;         // Base priority of process's threads
        DWORD   dwFlags;
        CHAR    szExeFile[MAX_PATH];    // Path
        */

    } while( Process32Next( hsp, &pe32 ) );

Is there any way to do it in linux/unix,. Ineed process ID, parent process Id and process name. I tryes to scan /proc/ folder but I cannot figure out the subfolders and files.

Thank you
The red icon (on the top-left) is a hand or a question mark ? I thought is a Q mark