<commit_before><?php
/* This class is part of the XP framework
 *
 * $Id$
 */

  uses('peer.server.Server', 'lang.RuntimeException');

  /**
   * Forking TCP/IP Server
   *
   * @ext      pcntl
   * @see      xp://peer.server.Server
   * @purpose  TCP/IP Server
   */
  class ForkingServer extends Server {
    
    /**
     * Service
     *
     * @access  public
     */
    function service() {
      if (!$this->socket->isConnected()) return FALSE;
      
      while ($m= &$this->socket->accept()) {

        // Have connection, fork child
        $pid= pcntl_fork();
        if (-1 == $pid) {       // Woops?
          return throw(new RuntimeException('Could not fork'));
        } else if ($pid) {      // Parent
          while (pcntl_waitpid(-1, $status, WNOHANG)) { }
          $m->close();
        } else {                // Child
          $this->notify(new ConnectionEvent(EVENT_CONNECTED, $m));
<commit_msg>- Do not loop - Use WUNTRACED   .  return for children which are stopped, and whose status has not been reported.<commit_after><?php
/* This class is part of the XP framework
 *
 * $Id$
 */

  uses('peer.server.Server', 'lang.RuntimeException');

  /**
   * Forking TCP/IP Server
   *
   * @ext      pcntl
   * @see      xp://peer.server.Server
   * @purpose  TCP/IP Server
   */
  class ForkingServer extends Server {
    
    /**
     * Service
     *
     * @access  public
     */
    function service() {
      if (!$this->socket->isConnected()) return FALSE;
      
      while ($m= &$this->socket->accept()) {

        // Have connection, fork child
        $pid= pcntl_fork();
        if (-1 == $pid) {       // Woops?
          return throw(new RuntimeException('Could not fork'));
        } else if ($pid) {      // Parent
          pcntl_waitpid(-1, $status, WUNTRACED);
          $m->close();
        } else {                // Child
          $this->notify(new ConnectionEvent(EVENT_CONNECTED, $m));

{'fraction_non_alphanumeric': 0.14883720930232558, 'fraction_numerical': 0.0020671834625322996, 'mean_word_length': 1.834553440702782, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3860685', 'n_tokens_mistral': 605, 'n_tokens_neox': 591, 'n_words': 151}