Replace the AGL JS Marker in the buffer.

@param $pBuffer string
@param string $pId JS belong to header or footer ID
@return string
964628
private function _processHtmlJsMarker(&$pBuffer, $pId)
	{
		$this->_js[$pId] = array_unique($this->_js[$pId]);

		$skinPath = $this->_getSkinRelativePath();
		$jsTags = array();
		foreach ($this->_js[$pId] as $js) {
			if (! filter_var($js, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED) and strpos($js, '//') === false) {
				$filePath = $skinPath
					. self::APP_HTTP_JS_DIR
					. DS
					. $js;
			} else {
				$filePath = $js;
			}
			$jsTags[] = '<script src="' . $filePath . '" type="text/javascript"></script>';
		}

		$footer  = ($pId === self::JS_MARKER_FOOTER) ? true : false;
		$pBuffer = str_replace(self::getJsMarker($footer), implode("\n", $jsTags) . "\n", $pBuffer);
		return $this;
	}
883596
public function actionAll( $pid ) {

		$modelClass = $this->modelService->getModelClass();

		$parent = $this->parentService->getById( $pid );

		if( isset( $parent ) ) {

			$dataProvider = $this->modelService->getPageByTypeUserId( CoreGlobal::TYPE_DEFAULT, $parent->id );

			return $this->render( 'all', [
				'dataProvider' => $dataProvider,
				'parent' => $parent,
				'visibilityMap' => $modelClass::$visibilityMap,
				'statusMap' => $modelClass::$statusMap
			]);
		}

		// Model not found
		throw new NotFoundHttpException( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) );
	}
661198
public function actionDelete( $id, $pid ) {

		$model	= $this->modelService->getById( $id );
		$parent = $this->parentService->getById( $pid );

		if( isset( $model ) && isset( $parent ) ) {

			$address = $this->addressService->getById( $model->modelId );

			// Delete Address and Mappings
			$this->addressService->delete( $address, [ 'admin' => true ] );

			// Trigger Ajax Success
			return AjaxUtil::generateSuccess( Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_REQUEST ) );
		}

		// Trigger Ajax Failure
		return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) );
	}
933178
public function endProcess($pid) {
		if (!$pid) {
			return;
		}

		$QueueProcesses = TableRegistry::get('Queue.QueueProcesses');
		/** @var \Queue\Model\Entity\QueueProcess $queuedProcess */
		$queuedProcess = $QueueProcesses->find()->where(['pid' => $pid])->firstOrFail();
		$queuedProcess->terminate = true;
		$QueueProcesses->saveOrFail($queuedProcess);
	}
1186392
private function _processHtmlTitleMarker(&$pBuffer)
	{
		$title = ($this->_titlePrefix and $this->_title) ? $this->_titlePrefix . $this->_titleSeparator . $this->_title : $this->_titlePrefix . $this->_title;
		$pBuffer = str_replace(self::getTitleMarker(), $title, $pBuffer);

		if (! isset($this->_meta['itemprop.name'])) {
			$this->addMeta('itemprop.name', array(
				'itemprop' => 'name',
				'content'  => $title
			));
		}

		if (! isset($this->_meta['og:title'])) {
			$this->addMeta('og:title', array(
				'property' => 'og:title',
				'content'  => $title
			));
		}

		return $this;
	}
422236
private function waitUntilStopped(int $pid): void
    {
        $wait = 5000; // 5ms
        $timeout = 1000000; // 1 sec
        $elapsed = 0;
        while (posix_getpgid($pid) !== false) {
            usleep($wait);
            $elapsed += $wait;
            if ($elapsed > $timeout) {
                throw new \Exception('Timeout while waiting for PHP-FPM to stop');
            }
        }
    }
990615
function addPid(content) {
    var shapeReg = /<(path|rect|circle|polygon|line|polyline|ellipse)\s/gi;
    var id = 0;
    content = content.replace(shapeReg, function (match) {
        return match + ("pid=\"" + id++ + "\" ");
    });
    return content;
}
142365
public static String pidMemoryUsage(int pid) throws IOException {
    Process process =
        new ProcessBuilder().command("ps", "-o", "pid,rss,vsz", "-p", Long.toString(pid)).start();

    BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));

    reader.readLine(); // Skip header

    String line = reader.readLine();
    String[] parts = line.trim().split("\\s+", 3);

    int readPid = Integer.parseInt(parts[0]);
    if (pid != readPid) {
      throw new RuntimeException("`ps` returned something unexpected: '" + line + "'");
    }

    long rss = Long.parseLong(parts[1]) * 1024;
    long vsz = Long.parseLong(parts[2]);

    // 0 pid, 1 rss, 2 vsz
    return String.format("%d\t%d", rss, vsz);
  }
1083205
private String getProducerId(final ProceedingJoinPoint pjp, final String aPId, final boolean withMethod) {
		if (!StringUtils.isEmpty(aPId))
			return aPId;

		String res = pjp.getSignature().getDeclaringTypeName();
		try {
			res = MoskitoUtils.producerName(res);
		} catch (final RuntimeException e) {
			if (logger.isTraceEnabled())
				logger.trace(e.getMessage(), e);
		}
		if (withMethod) {
			res += DOT + getMethodStatName(pjp.getSignature());
		}
		return res;
	}
952578
public function actionAll( $pid ) {

		$parent = $this->parentService->getById( $pid );

		if( isset( $parent ) ) {

			$modelClass = $this->modelService->getModelClass();

			$dataProvider = $this->modelService->getPage( [ 'conditions' => [ 'modelId' => $parent->id ] ] );

			return $this->render( 'all', [
				'dataProvider' => $dataProvider,
				'typeMap' => $modelClass::$typeMap,
				'parent' => $parent
			]);
		}

		// Model not found
		throw new NotFoundHttpException( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) );
	}
94680
public function getToken($pId = 0) {
    	if (isset($this->_tokens[$pId])) {
    		return $this->_tokens[$pId];
    	} else {
    		throw new PHPExcel_Calculation_Exception("Token with id $pId does not exist.");
    	}
    }
700297
public static function markParent($pid)
    {
        $coroutineId = \Swoole\Coroutine::getuid();
        if($coroutineId == $pid){
            return false;
        }
        static::$stackTree[$coroutineId] = $pid;
        return true;
    }
549625
public function updatePageTableField($pid, $sysLanguage, $fieldName, $fieldValue)
    {
        $tableName = 'pages';

        if (!empty($sysLanguage)) {
            // check if field is in overlay
            if ($this->isFieldInTcaTable('pages_language_overlay', $fieldName)) {
                // Field is in pages language overlay
                $tableName = 'pages_language_overlay';
            }
        }

        switch ($tableName) {
            case 'pages_language_overlay':
                // Update field in pages overlay (also logs update event and clear cache for this page)

                // check uid of pages language overlay
                $query     = 'SELECT uid
                                FROM pages_language_overlay
                               WHERE pid = ' . (int)$pid . '
                                 AND sys_language_uid = ' . (int)$sysLanguage;
                $overlayId = DatabaseUtility::getOne($query);

                if (empty($overlayId)) {
                    // No access

                    throw new AjaxException(
                        'message.error.no_language_overlay_found',
                        '[0x4FBF3C05]',
                        HttpUtility::HTTP_STATUS_BAD_REQUEST
                    );
                }

                // ################
                // UPDATE
                // ################

                $this->getDataHandler()->updateDB(
                    'pages_language_overlay',
                    (int)$overlayId,
                    array(
                        $fieldName => $fieldValue
                    )
                );
                break;
            case 'pages':
                // Update field in page (also logs update event and clear cache for this page)
                $this->getDataHandler()->updateDB(
                    'pages',
                    (int)$pid,
                    array(
                        $fieldName => $fieldValue
                    )
                );
                break;
        }

        return array();
    }
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]);
	}
464626
protected function partIdIsChildOfPart($partId, $parentPartId)
    {
        $parentPartId = $parentPartId.'.';
        return substr($partId, 0, strlen($parentPartId)) == $parentPartId;
    }
612665
protected function getPageId($pid)
    {
        $pid = (int)$pid;
        if ($pid > 0) {
            return $pid;
        }
        $row = BackendUtilityCore::getRecord('tt_content', abs($pid), 'uid,pid');
        return $row['pid'];
    }
764560
def _ps_extract_pid(self, line):
        
        this_pid = self.regex['pid'].sub(r'\g<1>', line)
        this_parent = self.regex['parent'].sub(r'\g<1>', line)
        
        # Return the main / parent PIDs
        return this_pid, this_parent