本文整理汇总了PHP中Process::getInternalId方法的典型用法代码示例。如果您正苦于以下问题:PHP Process::getInternalId方法的具体用法?PHP Process::getInternalId怎么用?PHP Process::getInternalId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Process
的用法示例。
在下文中一共展示了Process::getInternalId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fork
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));
}
}
}
示例2: fork
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));
}
}
}