title: Comparing file stat times
body: <p>I need to watch for the modification of a file on a Unix based system, and I do not have access to Boost. I am wondering if the following logic is sound. I figure it's probably inefficient, and I know I am wasting a ton of cycles by not sleeping at all in the while loop, but I don't have any estimate for how long the file will go in between modification, and I need to know relatively quickly:</p>
  
  <pre><code>std::time_t getTimeLastModified(const char* filename){
  
      struct stat fileattrib;
      stat(filename, &amp;fileattrib);
  
      return fileattrib.st_mtime;
  }
  
  int main(){
  
      std::time_t file1_modified_time = getTimeLastModified(coor_file.c_str());
  
      while(difftime(getTimeLastModified(coor_file.c_str()),file1_modified_time)==0){}
  
      // If program execution gets here, file has been modified
  }
  </code></pre>