public function signal_handler_sigint($signal_number)
	{
		// log that we received an exit request
		$this->received_exit_request(true);

		// kill child processes
		if (self::$parent_pid == getmypid())
		{
			foreach ($this->forked_children as $pid => &$pid_info)
			{
				if ($pid_info['status'] == self::STOPPED)
				{
					continue;
				}

				// tell helpers not to respawn
				if ($pid_info['status'] == self::HELPER)
				{
					$pid_info['respawn'] = false;
				}

				$this->safe_kill($pid, SIGINT, 'requesting child exit for pid: ' . $pid, self::LOG_LEVEL_INFO);
			}

			sleep(1);

			// checking for missed sigchild
			$this->signal_handler_sigchild(SIGCHLD);

			$start_time = time();

			// wait for child processes to go away
			while ($this->forked_children_count > 0)
			{
				if (time() > ($start_time + $this->children_max_timeout))
				{
					foreach ($this->forked_children as $pid => $child)
					{
						if ($child['status'] == self::STOPPED)
						{
							continue;
						}

						$this->safe_kill($pid, SIGKILL, 'force killing child pid: ' . $pid, self::LOG_LEVEL_INFO);

						// stop the child
						$this->forked_children[$pid]['status'] = self::STOPPED;
						$this->forked_children_count--;
					}
				}
				else
				{
					$this->log('waiting ' . ($start_time + $this->children_max_timeout - time()) . ' seconds for ' . $this->forked_children_count . ' children to clean up', self::LOG_LEVEL_INFO);
					sleep(1);
					$this->housekeeping_check();
				}
			}

			// make call back to parent exit function if it exists
			$this->invoke_callback($this->parent_function_exit, $parameters = array(self::$parent_pid, $signal_number), true);
		}
		else
		{
			// invoke child cleanup callback
			if (isset($this->child_bucket))
			{
				$this->invoke_callback($this->child_function_exit[$this->child_bucket], $parameters = array($this->child_bucket), true);
			}
		}

		exit(-1);
	}
public function signal_handler_sigint($signal_number)
	{
		// log that we received an exit request
		$this->received_exit_request(true);

		// kill child processes
		if (self::$parent_pid == getmypid())
		{
			foreach ($this->forked_children as $pid => &$pid_info)
			{
				if ($pid_info['status'] == self::STOPPED)
				{
					continue;
				}

				// tell helpers not to respawn
				if ($pid_info['status'] == self::HELPER)
				{
					$pid_info['respawn'] = false;
				}

				$this->safe_kill($pid, SIGINT, 'requesting child exit for pid: ' . $pid, self::LOG_LEVEL_INFO);
			}

			sleep(1);

			// checking for missed sigchild
			$this->signal_handler_sigchild(SIGCHLD);

			$start_time = time();

			// wait for child processes to go away
			while ($this->forked_children_count > 0)
			{
				if (time() > ($start_time + $this->children_max_timeout))
				{
					foreach ($this->forked_children as $pid => $child)
					{
						if ($child['status'] == self::STOPPED)
						{
							continue;
						}

						$this->safe_kill($pid, SIGKILL, 'force killing child pid: ' . $pid, self::LOG_LEVEL_INFO);

						// stop the child
						$this->forked_children[$pid]['status'] = self::STOPPED;
						$this->forked_children_count--;
					}
				}
				else
				{
					$this->log('waiting ' . ($start_time + $this->children_max_timeout - time()) . ' seconds for ' . $this->forked_children_count . ' children to clean up', self::LOG_LEVEL_INFO);
					sleep(1);
					$this->housekeeping_check();
				}
			}

			// make call back to parent exit function if it exists
			$this->invoke_callback($this->parent_function_exit, $parameters = array(self::$parent_pid, $signal_number), true);
		}
		else
		{
			// invoke child cleanup callback
			if (isset($this->child_bucket))
			{
				$this->invoke_callback($this->child_function_exit[$this->child_bucket], $parameters = array($this->child_bucket), true);
			}
		}

		exit(-1);
	}
public function signal_handler_sigint ( $ signal_number ) { // log that we received an exit request $ this -> received_exit_request ( true ) ; // kill child processes if ( self :: $ parent_pid == getmypid ( ) ) { foreach ( $ this -> forked_children as $ pid => & $ pid_info ) { if ( $ pid_info [ 'status' ] == self :: STOPPED ) { continue ; } // tell helpers not to respawn if ( $ pid_info [ 'status' ] == self :: HELPER ) { $ pid_info [ 'respawn' ] = false ; } $ this -> safe_kill ( $ pid , SIGINT , 'requesting child exit for pid: ' . $ pid , self :: LOG_LEVEL_INFO ) ; } sleep ( 1 ) ; // checking for missed sigchild $ this -> signal_handler_sigchild ( SIGCHLD ) ; $ start_time = time ( ) ; // wait for child processes to go away while ( $ this -> forked_children_count > 0 ) { if ( time ( ) > ( $ start_time + $ this -> children_max_timeout ) ) { foreach ( $ this -> forked_children as $ pid => $ child ) { if ( $ child [ 'status' ] == self :: STOPPED ) { continue ; } $ this -> safe_kill ( $ pid , SIGKILL , 'force killing child pid: ' . $ pid , self :: LOG_LEVEL_INFO ) ; // stop the child $ this -> forked_children [ $ pid ] [ 'status' ] = self :: STOPPED ; $ this -> forked_children_count -- ; } } else { $ this -> log ( 'waiting ' . ( $ start_time + $ this -> children_max_timeout - time ( ) ) . ' seconds for ' . $ this -> forked_children_count . ' children to clean up' , self :: LOG_LEVEL_INFO ) ; sleep ( 1 ) ; $ this -> housekeeping_check ( ) ; } } // make call back to parent exit function if it exists $ this -> invoke_callback ( $ this -> parent_function_exit , $ parameters = array ( self :: $ parent_pid , $ signal_number ) , true ) ; } else { // invoke child cleanup callback if ( isset ( $ this -> child_bucket ) ) { $ this -> invoke_callback ( $ this -> child_function_exit [ $ this -> child_bucket ] , $ parameters = array ( $ this -> child_bucket ) , true ) ; } } exit ( - 1 ) ; }
Handle both parent and child registered sigint callbacks

User terminated by CTRL-C (detected only by the parent)

@param int $signal_number Is the signal that called this function.
@return void
@access public
Handle both parent and child registered sigint callbacks