title: Daemon is performed only once
body: <p>I want to write a daemon which will write the contents of the folder every 5 seconds. Unfortunately, this is done only once. What to do to be done cyclically? I dont have any idea how to do.</p>
  
  <pre><code>struct dirent *file;
  struct stat file_details;
  while (1)
  {    
      while((file=readdir(source))!=NULL)
      {
          if(file-&gt;d_type!=DT_REG) continue;
          fprintf(stderr,"Name: %s \n",file-&gt;d_name);
      }
  
      sleep(5);
  }
  </code></pre>