title: Read proc stat information
body: <p>Hello I require following information about process with some PID:</p>
  
  <p>name, ppid, state, #ofOpenFiles, #ofThreads</p>
  
  <p>I know the example of /proc/pid/stat file is like :</p>
  
  <blockquote>
    <p>15 (watchdog/1) S 2 0 0 0 -1 69239104 0 0 0 0 0 69 0 0 -100 0 1 0 6 0 0 18446744073709551615 0 0 0 0 0 0 0 2147483647 0 18446744073709551615 0 0 17 1 99 1 0 0 0 0 0 0 0 0 0 0 0</p>
  </blockquote>
  
  <p>My current attempt of parsing such file:</p>
  
  <pre><code>FILE *fp;
             char buff[255];
             fp= fopen("/proc/123/stat", "r");
             if(fp == NULL){
  
             }else{
  
               fscanf(fp, "%d %s %c %d %d %d %d %d %u %lu ....", &amp;pid, &amp;name, &amp;ppid......)
               fclose(fp);
             }
  </code></pre>
  
  <p>I don't find this very good method. How to do this?</p>