public function fork(Process $children, $user_name = null, $group_name = null)
 {
     if ($this->allocateSHMPerChildren()) {
         $children->setSHMSegment(new SHMCache(uniqid('process_manager;shm_per_children' . $children->getInternalId()), $this->allocateSHMPerChildren));
     }
     pcntl_sigprocmask(SIG_BLOCK, array(SIGCHLD));
     $pid = pcntl_fork();
     // Error
     if ($pid == -1) {
         throw new RuntimeException('pcntl_fork() returned -1, are you sure you are running the script from CLI?');
     } else {
         if (!$pid) {
             if (!is_null($group_name)) {
                 if (!$this->setGroup($group_name)) {
                     throw new RuntimeException('set group_name failed. are you sure you have the privileges?');
                 }
             }
             if (!is_null($user_name)) {
                 if (!$this->setUser($user_name)) {
                     throw new RuntimeException('set user_name failed. are you sure you have the privileges?');
                 }
             }
             $children->run();
             exit;
             // redundant, added only for clarity
         } else {
             $children->setStarted(true);
             $this->children[] = $children;
             // Store the children's PID
             $children->setPid($pid);
             pcntl_sigprocmask(SIG_UNBLOCK, array(SIGCHLD));
         }
     }
 }
 public function fork(Process $children)
 {
     if ($this->allocateSHMPerChildren()) {
         $children->setSHMSegment(new \Zebra\Ipcs\SHMCache(\uniqid('process_manager;shm_per_children' . $children->getInternalId()), $this->allocateSHMPerChildren));
     }
     \pcntl_sigprocmask(SIG_BLOCK, array(SIGCHLD));
     $pid = \pcntl_fork();
     // Error
     if ($pid == -1) {
         throw new RuntimeException('pcntl_fork() returned -1, are you sure you are running the script from CLI?');
     } else {
         if (!$pid) {
             $children->run();
             exit;
             // redundant, added only for clarity
         } else {
             $children->setStarted(true);
             $this->children[] = $children;
             // Store the children's PID
             $children->setPid($pid);
             \pcntl_sigprocmask(SIG_UNBLOCK, array(SIGCHLD));
         }
     }
 }