title: Reading already opened file continuously using C
body: <p>I am implementing a low weight application where I have to open and read the /proc/pid or tid/task/stat details very often. If the application is multithreaded I have to read more stat files. So opening, reading and closing makes my monitoring application really slow. Is there a solution to avoid opening the file repeatedly and still able to read the updated content?</p>
  
  <p>I ran the following experiment but I don't see success. I change the data in "test.txt" but the new data is not read. Is it because the file is not updated in memory? What happens when i modify and save "test.txt"?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  int main()
  {
      FILE * pFile;
      char mystring [100];
      pFile = fopen ("test.txt" , "r");
      while(1){
          if (pFile == NULL) perror ("Error opening file");
          if ( fgets (mystring , 100 , pFile) != NULL ){
              puts (mystring);
              fseek ( pFile , 0 , SEEK_SET );
          }
          sleep(1);
      }
      fclose (pFile);
      return 0;
  }
  </code></pre>