english/libraries/joomla/application/cli/daemon.php
/**
	 * Method to put the application into the background.
	 *
	 * @return  boolean
	 *
	 * @since   11.1
	 * @throws  ApplicationException
	 */
Method to put the application into the background.
@return  boolean


Method to put the application into the background . @return boolean
protected function daemonize()
	{
				if ($this->isActive()) {
			JLog::add($this->name.' daemon is still running. Exiting the application.', JLog::EMERGENCY);
			return false;
		}
		$this->safeMode = !!@ ini_get('safe_mode');
		$this->processId = 0;
		$this->running = false;
		try {
			$this->fork();
		}
		catch (ApplicationException $e) {
			JLog::add('Unable to fork.', JLog::EMERGENCY);
			return false;
		}
		if ($this->processId < 1) {
			JLog::add('The process id is invalid; the fork failed.', JLog::EMERGENCY);
			return false;
		}
		@ umask(0);
		if (!$this->writeProcessIdFile()) {
			JLog::add('Unable to write the pid file at: '.$this->config->get('application_pid_file'), JLog::EMERGENCY);
			return false;
		}
		if (!$this->changeIdentity()) {
			if ($this->config->get('application_require_identity')) {
				JLog::add('Unable to change process owner.', JLog::CRITICAL);
				return false;
			}
			else {
				JLog::add('Unable to change process owner.', JLog::WARNING);
			}
		}
		if (!$this->setupSignalHandlers()) {
			return false;
		}
		@ chdir($this->config->get('application_directory'));
		return true;
	}
protected function daemonize ( ) { if ( $ this -> isActive ( ) ) { JLog :: add ( $ this -> name . ' daemon is still running. Exiting the application.' , JLog :: EMERGENCY ) ; return false ; } $ this -> safeMode = ! ! @ ini_get ( 'safe_mode' ) ; $ this -> processId = 0 ; $ this -> running = false ; try { $ this -> fork ( ) ; } catch ( ApplicationException $ e ) { JLog :: add ( 'Unable to fork.' , JLog :: EMERGENCY ) ; return false ; } if ( $ this -> processId < 1 ) { JLog :: add ( 'The process id is invalid; the fork failed.' , JLog :: EMERGENCY ) ; return false ; } @ umask ( 0 ) ; if ( ! $ this -> writeProcessIdFile ( ) ) { JLog :: add ( 'Unable to write the pid file at: ' . $ this -> config -> get ( 'application_pid_file' ) , JLog :: EMERGENCY ) ; return false ; } if ( ! $ this -> changeIdentity ( ) ) { if ( $ this -> config -> get ( 'application_require_identity' ) ) { JLog :: add ( 'Unable to change process owner.' , JLog :: CRITICAL ) ; return false ; } else { JLog :: add ( 'Unable to change process owner.' , JLog :: WARNING ) ; } } if ( ! $ this -> setupSignalHandlers ( ) ) { return false ; } @ chdir ( $ this -> config -> get ( 'application_directory' ) ) ; return true ; }
Method to put the application into the background.
Method to put the application into the background .
// Is there already an active daemon running?
 // Reset Process Information // Fork process! // Verify the process id is valid. // Clear the umask. // Write out the process id file for concurrency management. // Attempt to change the identity of user running the process. // If the identity change was required then we need to return false. // Setup the signal handlers for the daemon. // Change the current working directory to the application working directory.