title: Creating a daemon in Linux
body: <p>In Linux I want to add a daemon that cannot be stopped and which monitors filesystem changes.
  If any changes are detected, it should write the path to the console where it was started plus a newline.</p>
  
  <p>I already have the filesystem changing code almost ready but I cannot figure out how to create a daemon.</p>
  
  <p>My code is from here: <a href="http://www.yolinux.com/TUTORIALS/ForkExecProcesses.html">http://www.yolinux.com/TUTORIALS/ForkExecProcesses.html</a></p>
  
  <p>What to do after the fork?</p>
  
  <pre><code>int main (int argc, char **argv) {
  
    pid_t pID = fork();
    if (pID == 0)  {              // child
            // Code only executed by child process    
        sIdentifier = "Child Process: ";
      }
      else if (pID &lt; 0) {
          cerr &lt;&lt; "Failed to fork" &lt;&lt; endl;
          exit(1);
         // Throw exception
      }
      else                                   // parent
      {
        // Code only executed by parent process
  
        sIdentifier = "Parent Process:";
      }       
  
      return 0;
  }
  </code></pre>