Creates a new fork instance.

@param int          $pid   Process id
@param SharedMemory $shm   Shared memory
@param bool         $debug Debug mode

@return Fork A new fork instance
482239
public function createFork($pid, SharedMemory $shm, $debug = false)
    {
        return new Fork($pid, $shm, $debug);
    }
587688
public function daemonize()
    {
        $pid = pcntl_fork();

        if ($pid === -1) {
            throw new \RuntimeException('Unable to fork child process.');
        } else if ($pid) {
            exit;
        }

        // Make sub process as session leader
        posix_setsid();

        if ($pid === -1) {
            throw new \RuntimeException('Unable to fork child process.');
        } else if ($pid) {
            exit;
        }

        // Prepare the resource
        $this->prepared = false;
        $pid = posix_getpid();
        $this->ppid = $this->pid;
        $this->pid = $pid;
        $this->queue = null;
        $this->process = new Process($this, $this->pid, $this->ppid);
        $this->children = array();
        $this->prepared = true;

        return $this;
    }
270780
public function save(Debuggee $debuggee, array $breakpoints)
    {
        $shmid = shm_attach($this->sysvKey);
        if ($shmid === false) {
            throw new \RuntimeException(
                'Failed to attach to the shared memory'
            );
        }
        $result = shm_put_var($shmid, self::VAR_KEY, [$debuggee->id(), $breakpoints]);
        shm_detach($shmid);
        return $result;
    }
1137597
public function setDebug($debug)
	{
		$previous = $this->debug;
		$this->debug = (boolean) $debug;

		return $previous;
	}
471222
def zthread_fork(ctx, func, *args, **kwargs):
    
    a = ctx.socket(zmq.PAIR)
    a.setsockopt(zmq.LINGER, 0)
    a.setsockopt(zmq.RCVHWM, 100)
    a.setsockopt(zmq.SNDHWM, 100)
    a.setsockopt(zmq.SNDTIMEO, 5000)
    a.setsockopt(zmq.RCVTIMEO, 5000)
    b = ctx.socket(zmq.PAIR)
    b.setsockopt(zmq.LINGER, 0)
    b.setsockopt(zmq.RCVHWM, 100)
    b.setsockopt(zmq.SNDHWM, 100)
    b.setsockopt(zmq.SNDTIMEO, 5000)
    a.setsockopt(zmq.RCVTIMEO, 5000)
    iface = "inproc://%s" % binascii.hexlify(os.urandom(8))
    a.bind(iface)
    b.connect(iface)

    thread = threading.Thread(target=func, args=((ctx, b) + args), kwargs=kwargs)
    thread.daemon = False
    thread.start()

    return a
754915
public function terminateProcess($pid, $sig = SIGTERM) {
		if (!$pid) {
			return;
		}

		$killed = false;
		if (function_exists('posix_kill')) {
			$killed = posix_kill($pid, $sig);
		}
		if (!$killed) {
			exec('kill -' . $sig . ' ' . $pid);
		}
		sleep(1);

		$QueueProcesses = TableRegistry::get('Queue.QueueProcesses');
		$QueueProcesses->deleteAll(['pid' => $pid]);
	}
551141
protected function killProcess($pid, $sig, $wait = 0)
    {
        Process::kill($pid, $sig);

        if ($wait) {
            $start = time();

            do {
                if (! $this->isRunning($pid)) {
                    break;
                }

                usleep(100000);
            } while (time() < $start + $wait);
        }

        return $this->isRunning($pid);
    }
960591
public function setCurlDebugging($debug = true) {
        $this->blocktrailClient->setCurlDebugging($debug);
        $this->dataClient->setCurlDebugging($debug);
    }
606716
def create_fork(self):
        
        headers, data = self._requester.requestJsonAndCheck(
            "POST",
            self.url + "/forks"
        )
        return Gist(self._requester, headers, data, completed=True)
1283054
public function start()
    {
        if (!$this->isIPC) {
            throw new Exception('Fatal error, unable to create SHM segments for process communications');
        }

        pcntl_signal(SIGCHLD, SIG_IGN);

        $pid = pcntl_fork();
        if ($pid === 0) {
            $this->isChild = true;
            sleep(1);

            pcntl_signal(SIGUSR1, [$this, 'sigHandler']);

            if ($this->guid !== 0) {
                posix_setgid($this->guid);
            }
            if ($this->puid !== 0) {
                posix_setuid($this->puid);
            }
            $this->run();

            exit(0);
        } else {
            $this->isChild = false;
            $this->running = true;
            $this->pid = $pid;
        }
    }
384953
def reopen_after_fork!
    logger.debug { "#{self.class}##{__method__} fork detected!" } if forked?

    @mutex = Monitor.new
    @dispatch_shutdown_cond = @mutex.new_cond
    @event_queue = QueueWithPipe.new

    @dispatcher = nil if @dispatcher and not @dispatcher.alive?

    update_pid!  # from Forked
  end
1259663
public function show($process, $debug)
    {
        $this->title('Switch debug mode command :');
        if ($process) {
            $this->info("\nThe debug mode is ".($debug ? 'enabled' : 'disabled')."\n");
        } else {
            $this->error("\nThe debug mode won't be switched\n");
        }
    }
665660
public function fork()
    {
        if (!function_exists('pcntl_fork')) {
            return false;
        }
        $pid = pcntl_fork();

        if ($pid == -1) {
            //failure
            return false;
        } elseif ($pid) {
            return true;
        } else {
            $this->start();
            exit(0);
        }
    }
291282
public static PID getInstance(String pidString) {
        try {
            return new PID(pidString);
        } catch (MalformedPIDException e) {
            throw new FaultException("Malformed PID: " + e.getMessage(), e);
        }
    }
401019
public function initialize($pid)
	{
		if($this->user->tests()->instance($pid)->start())
			return true;
		else
			return false;
	}
355214
public static function create($paths, $cache = null, $debug = false)
    {
        $wise = new self($debug);

        if ($cache) {
            $wise->setCacheDir($cache);
        }

        $locator = new FileLocator($paths);
        $resolver = new LoaderResolver(
            array(
                new Loader\IniFileLoader($locator),
                new Loader\JsonFileLoader($locator),
                new Loader\PhpFileLoader($locator),
                new Loader\XmlFileLoader($locator),
                new Loader\YamlFileLoader($locator),
            )
        );

        $wise->setCollector(new Resource\ResourceCollector());
        $wise->setLoader(new DelegatingLoader($resolver));

        $resolver->setResourceCollector($wise->getCollector());
        $resolver->setWise($wise);

        return $wise;
    }
563194
def create(cls, parent, child, relation_type, index=None):
        """"""
        try:
            with db.session.begin_nested():
                obj = cls(parent_id=parent.id,
                          child_id=child.id,
                          relation_type=relation_type,
                          index=index)
                db.session.add(obj)
        except IntegrityError:
            raise Exception("PID Relation already exists.")
            # msg = "PIDRelation already exists: " \
            #       "{0} -> {1} ({2})".format(
            #         parent_pid, child_pid, relation_type)
            # logger.exception(msg)
            # raise Exception(msg)
        return obj