public function helper_process_spawn($function_name, array $arguments = array(), $identifier = '', $respawn = true)
	{
		if ((is_array($function_name) && method_exists($function_name[0], $function_name[1])) || function_exists($function_name))
		{
			// init the IPC sockets
			list($socket_child, $socket_parent) = $this->ipc_init();

			// do not process signals while we are forking
			pcntl_async_signals(false);
			$pid = pcntl_fork();

			if ($pid == -1)
			{
				die("Forking error!\n");
			}
			elseif ($pid == 0)
			{
				/*
				 * Child process
				 */

				// set child properties
				$this->child_bucket = self::DEFAULT_BUCKET;

				pcntl_async_signals(true);

				// close our socket (we only need the one to the parent)
				socket_close($socket_child);

				// execute the function
				$result = call_user_func_array($function_name, $arguments);

				// send the response to the parent
				self::socket_send($socket_parent, $result);

				exit(0);
			}
			else
			{
				/*
				 * Parent process
				 */

				pcntl_async_signals(true);
				$this->log('Spawned new helper process with pid ' . $pid, self::LOG_LEVEL_INFO);

				// close our socket (we only need the one to the child)
				socket_close($socket_parent);

				// track the child
				$this->forked_children[$pid] = array(
					'ctime' => time(),
					'identifier' => $identifier,
					'status' => self::HELPER,
					'bucket' => self::DEFAULT_BUCKET,
					'respawn' => $respawn,
					'function' => $function_name,
					'arguments' => $arguments,
					'socket' => $socket_child,
					'last_active' => microtime(true),
				);
				$this->forked_children_count++;
			}
		}
		else
		{
			$this->log("Unable to spawn undefined helper function '" . $function_name . "'", self::LOG_LEVEL_CRIT);
		}
	}
public function helper_process_spawn($function_name, array $arguments = array(), $identifier = '', $respawn = true)
	{
		if ((is_array($function_name) && method_exists($function_name[0], $function_name[1])) || function_exists($function_name))
		{
			// init the IPC sockets
			list($socket_child, $socket_parent) = $this->ipc_init();

			// do not process signals while we are forking
			pcntl_async_signals(false);
			$pid = pcntl_fork();

			if ($pid == -1)
			{
				die("Forking error!\n");
			}
			elseif ($pid == 0)
			{
				/*
				 * Child process
				 */

				// set child properties
				$this->child_bucket = self::DEFAULT_BUCKET;

				pcntl_async_signals(true);

				// close our socket (we only need the one to the parent)
				socket_close($socket_child);

				// execute the function
				$result = call_user_func_array($function_name, $arguments);

				// send the response to the parent
				self::socket_send($socket_parent, $result);

				exit(0);
			}
			else
			{
				/*
				 * Parent process
				 */

				pcntl_async_signals(true);
				$this->log('Spawned new helper process with pid ' . $pid, self::LOG_LEVEL_INFO);

				// close our socket (we only need the one to the child)
				socket_close($socket_parent);

				// track the child
				$this->forked_children[$pid] = array(
					'ctime' => time(),
					'identifier' => $identifier,
					'status' => self::HELPER,
					'bucket' => self::DEFAULT_BUCKET,
					'respawn' => $respawn,
					'function' => $function_name,
					'arguments' => $arguments,
					'socket' => $socket_child,
					'last_active' => microtime(true),
				);
				$this->forked_children_count++;
			}
		}
		else
		{
			$this->log("Unable to spawn undefined helper function '" . $function_name . "'", self::LOG_LEVEL_CRIT);
		}
	}
public function helper_process_spawn ( $ function_name , array $ arguments = array ( ) , $ identifier = '' , $ respawn = true ) { if ( ( is_array ( $ function_name ) && method_exists ( $ function_name [ 0 ] , $ function_name [ 1 ] ) ) || function_exists ( $ function_name ) ) { // init the IPC sockets list ( $ socket_child , $ socket_parent ) = $ this -> ipc_init ( ) ; // do not process signals while we are forking pcntl_async_signals ( false ) ; $ pid = pcntl_fork ( ) ; if ( $ pid == - 1 ) { die ( "Forking error!\n" ) ; } elseif ( $ pid == 0 ) { /*
				 * Child process
				 */ // set child properties $ this -> child_bucket = self :: DEFAULT_BUCKET ; pcntl_async_signals ( true ) ; // close our socket (we only need the one to the parent) socket_close ( $ socket_child ) ; // execute the function $ result = call_user_func_array ( $ function_name , $ arguments ) ; // send the response to the parent self :: socket_send ( $ socket_parent , $ result ) ; exit ( 0 ) ; } else { /*
				 * Parent process
				 */ pcntl_async_signals ( true ) ; $ this -> log ( 'Spawned new helper process with pid ' . $ pid , self :: LOG_LEVEL_INFO ) ; // close our socket (we only need the one to the child) socket_close ( $ socket_parent ) ; // track the child $ this -> forked_children [ $ pid ] = array ( 'ctime' => time ( ) , 'identifier' => $ identifier , 'status' => self :: HELPER , 'bucket' => self :: DEFAULT_BUCKET , 'respawn' => $ respawn , 'function' => $ function_name , 'arguments' => $ arguments , 'socket' => $ socket_child , 'last_active' => microtime ( true ) , ) ; $ this -> forked_children_count ++ ; } } else { $ this -> log ( "Unable to spawn undefined helper function '" . $ function_name . "'" , self :: LOG_LEVEL_CRIT ) ; } }
Spawns a helper process

Spawns a new helper process to perform duties under the parent server
process without accepting connections. Helper processes can optionally
be respawned when they die.

@access public
@param string $function_name Helper function to call.
@param array  $arguments     Function arguments.
@param string $identifier    Helper process unique identifier.
@param bool   $respawn       Whether to respawn the helper process when it dies.
@return void
Spawns a helper process