本文整理匯總了PHP中Process::setSHMSegment方法的典型用法代碼示例。如果您正苦於以下問題:PHP Process::setSHMSegment方法的具體用法?PHP Process::setSHMSegment怎麽用?PHP Process::setSHMSegment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Process
的用法示例。
在下文中一共展示了Process::setSHMSegment方法的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));
}
}
}