protected function detach()
    {
        $this->getLogger()->debug('Detaching the ' . $this->name . ' daemon.');

        // Attempt to fork the process.
        $pid = $this->fork();

        // If the pid is positive then we successfully forked, and can close this application.
        if ($pid) {
            // Add the log entry for debugging purposes and exit gracefully.
            $this->getLogger()->debug('Ending ' . $this->name . ' parent process');

            $this->close();
        } else // We are in the forked child process.
        {
            // Setup some protected values.
            $this->exiting = false;
            $this->running = true;

            // Set the parent to self.
            $this->parentId = $this->processId;
        }
    }
protected function detach()
    {
        $this->getLogger()->debug('Detaching the ' . $this->name . ' daemon.');

        // Attempt to fork the process.
        $pid = $this->fork();

        // If the pid is positive then we successfully forked, and can close this application.
        if ($pid) {
            // Add the log entry for debugging purposes and exit gracefully.
            $this->getLogger()->debug('Ending ' . $this->name . ' parent process');

            $this->close();
        } else // We are in the forked child process.
        {
            // Setup some protected values.
            $this->exiting = false;
            $this->running = true;

            // Set the parent to self.
            $this->parentId = $this->processId;
        }
    }
protected function detach ( ) { $ this -> getLogger ( ) -> debug ( 'Detaching the ' . $ this -> name . ' daemon.' ) ; // Attempt to fork the process. $ pid = $ this -> fork ( ) ; // If the pid is positive then we successfully forked, and can close this application. if ( $ pid ) { // Add the log entry for debugging purposes and exit gracefully. $ this -> getLogger ( ) -> debug ( 'Ending ' . $ this -> name . ' parent process' ) ; $ this -> close ( ) ; } else // We are in the forked child process. { // Setup some protected values. $ this -> exiting = false ; $ this -> running = true ; // Set the parent to self. $ this -> parentId = $ this -> processId ; } }
This is truly where the magic happens.  This is where we fork the process and kill the parent
process, which is essentially what turns the application into a daemon.

@return  void

@since   2.0
@throws  \RuntimeException
This is truly where the magic happens . This is where we fork the process and kill the parent process which is essentially what turns the application into a daemon .