当前位置: 首页>>代码示例>>PHP>>正文


PHP getmypid函数代码示例

本文整理汇总了PHP中getmypid函数的典型用法代码示例。如果您正苦于以下问题:PHP getmypid函数的具体用法?PHP getmypid怎么用?PHP getmypid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getmypid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getRandomBytes

 private function getRandomBytes($count)
 {
     $bytes = '';
     if (function_exists('openssl_random_pseudo_bytes') && strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
         // OpenSSL slow on Win
         $bytes = openssl_random_pseudo_bytes($count);
     }
     if ($bytes === '' && @is_readable('/dev/urandom') && ($hRand = @fopen('/dev/urandom', 'rb')) !== FALSE) {
         $bytes = fread($hRand, $count);
         fclose($hRand);
     }
     if (strlen($bytes) < $count) {
         $bytes = '';
         if ($this->randomState === null) {
             $this->randomState = microtime();
             if (function_exists('getmypid')) {
                 $this->randomState .= getmypid();
             }
         }
         for ($i = 0; $i < $count; $i += 16) {
             $this->randomState = md5(microtime() . $this->randomState);
             if (PHP_VERSION >= '5') {
                 $bytes .= md5($this->randomState, true);
             } else {
                 $bytes .= pack('H*', md5($this->randomState));
             }
         }
         $bytes = substr($bytes, 0, $count);
     }
     return $bytes;
 }
开发者ID:vkaran101,项目名称:sase,代码行数:31,代码来源:Bcrypt.php

示例2: getPid

 protected function getPid()
 {
     if (is_null($this->pid)) {
         $this->pid = getmypid();
     }
     return $this->pid;
 }
开发者ID:younkim,项目名称:Aoe_CacheStats,代码行数:7,代码来源:Cache.php

示例3: __construct

 public function __construct()
 {
     echo "[*] PocketMine-MP set-up wizard\n";
     echo "[*] Please select a language:\n";
     foreach (InstallerLang::$languages as $short => $native) {
         echo " {$native} => {$short}\n";
     }
     do {
         echo "[?] Language (en): ";
         $lang = strtolower($this->getInput("en"));
         if (!isset(InstallerLang::$languages[$lang])) {
             echo "[!] Couldn't find the language\n";
             $lang = false;
         }
     } while ($lang == false);
     $this->lang = new InstallerLang($lang);
     echo "[*] " . $this->lang->language_has_been_selected . "\n";
     if (!$this->showLicense()) {
         \pocketmine\kill(getmypid());
         exit(-1);
     }
     echo "[?] " . $this->lang->skip_installer . " (y/N): ";
     if (strtolower($this->getInput()) === "y") {
         return;
     }
     echo "\n";
     $this->welcome();
     $this->generateBaseConfig();
     $this->generateUserFiles();
     $this->networkFunctions();
     $this->endWizard();
 }
开发者ID:rryy,项目名称:PocketMine-MP,代码行数:32,代码来源:Installer.php

示例4: _exclusiveLock

 function _exclusiveLock($fname = false)
 {
     $mutex =& $this->_mutex();
     while (true) {
         $timestamp = $mutex->lockTS();
         // Note: This does not lock, only checks what the timestamp is.
         if ($timestamp === false) {
             if (!$mutex->lock()) {
                 eZDebug::writeWarning("Failed to acquire lock for file " . $this->filePath);
                 return false;
             }
             $mutex->setMeta('pid', getmypid());
             return true;
         }
         if ($timestamp >= time() - $this->lifetime) {
             usleep(500000);
             // Sleep 0.5 second
             continue;
         }
         $oldPid = $mutex->meta('pid');
         if (is_numeric($oldPid) && $oldPid != 0 && function_exists('posix_kill')) {
             posix_kill($oldPid, 9);
         }
         if (!$mutex->steal()) {
             eZDebug::writeWarning("Failed to steal lock for file " . $this->filePath . " from PID {$oldPid}");
             return false;
         }
         $mutex->setMeta('pid', getmypid());
         return true;
     }
 }
开发者ID:schwabokaner,项目名称:ezpublish-legacy,代码行数:31,代码来源:ezfsfilehandler.php

示例5: Observe

 public function Observe($obj, $ltype = OBSERVE_INFO)
 {
     if (is_object($obj) || is_array($obj)) {
         $msg = "<pre>" . print_r($obj, 1) . "</pre>";
     } else {
         $msg = $obj;
     }
     $msg = date("Y-m-d H:i:s:u") . "\t" . getmypid() . "\t" . str_replace(array("\t", "\r", "\n"), array(" ", " ", " "), $msg);
     if ($this->eventtype == null || $this->eventtype & $ltype) {
         // this can occur if the file has been closed due to the php script terminating
         if (!$this->fileIsOpen) {
             $this->Init();
             fwrite($this->fh, "WARN:\t" . date("Y-m-d H:i:s:u") . "\tfilehandle was re-opened due to Observe being called after destruction\r\n");
         }
         switch ($ltype) {
             case OBSERVE_DEBUG:
                 fwrite($this->fh, "DEBUG:\t{$msg}\r\n");
                 break;
             case OBSERVE_QUERY:
                 //fwrite($this->fh, "QUERY:\t" . $this->FormatTrace(debug_backtrace()) . " " . $msg . "\r\n");
                 fwrite($this->fh, "QUERY:\t" . $msg . "\r\n");
                 break;
             case OBSERVE_FATAL:
                 fwrite($this->fh, "FATAL:\t{$msg}\r\n");
                 break;
             case OBSERVE_INFO:
                 fwrite($this->fh, "INFO:\t{$msg}\r\n");
                 break;
             case OBSERVE_WARN:
                 fwrite($this->fh, "WARN:\t{$msg}\r\n");
                 break;
         }
     }
 }
开发者ID:niceboy120,项目名称:phreeze,代码行数:34,代码来源:ObserveToFile.php

示例6: Log

 /**
  * This will log a message to the Qcodo Log.  Location of the log file is defined in __QCODO_LOG__
  * 
  * By default, this will log a "Normal" level log entry in the "default" Qcodo log file, which is
  * located at __QCODO_LOG__/default.log.txt
  * 
  * Either parameter can be overridden.
  * 
  * @param string $strMessage
  * @param integer $intLogLevel
  * @param string $strLogModule
  * @return void
  */
 public static function Log($strMessage, $intLogLevel = QLogLevel::Normal, $strLogModule = 'default')
 {
     // Cancel out if log level is too low
     if ($intLogLevel > self::$MinimumLogLevel) {
         return;
     }
     // Setup Log Path
     if (!defined('__QCODO_LOG__')) {
         throw new QCallerException('__QCODO_LOG__ must be defined before running QLog::Log');
     }
     // Cancel out if log path is null
     if (!__QCODO_LOG__) {
         return;
     }
     // Create the Log Directory if it does NOT yet exist
     if (!is_dir(__QCODO_LOG__)) {
         QApplication::MakeDirectory(__QCODO_LOG__, 0777);
     }
     // Setup the Line
     $strLine = sprintf("%5s | %s | %s | %s\r\n", getmypid(), QLogLevel::$NameArray[$intLogLevel], QDateTime::Now()->NowToString(QDateTime::FormatIso), self::FormatMessage($strMessage));
     // Open the File for Writing
     $strLogFilePath = __QCODO_LOG__ . '/' . $strLogModule . self::$Extension;
     $objFile = fopen($strLogFilePath, 'a');
     // Write the Line
     fwrite($objFile, $strLine);
     fclose($objFile);
 }
开发者ID:klucznik,项目名称:qcodo,代码行数:40,代码来源:QLog.class.php

示例7: killRedis

function killRedis($pid)
{
    if (getmypid() !== $pid) {
        return;
        // don't kill from a forked worker
    }
    $config = file_get_contents(REDIS_CONF);
    if (!preg_match('#^\\s*pidfile\\s+([^\\s]+)#m', $config, $matches)) {
        return;
    }
    $pidFile = TEST_MISC . '/' . $matches[1];
    if (file_exists($pidFile)) {
        $pid = trim(file_get_contents($pidFile));
        posix_kill((int) $pid, 9);
        if (is_file($pidFile)) {
            unlink($pidFile);
        }
    }
    // Remove the redis database
    if (!preg_match('#^\\s*dir\\s+([^\\s]+)#m', $config, $matches)) {
        return;
    }
    $dir = $matches[1];
    if (!preg_match('#^\\s*dbfilename\\s+([^\\s]+)#m', $config, $matches)) {
        return;
    }
    $filename = TEST_MISC . '/' . $dir . '/' . $matches[1];
    if (is_file($filename)) {
        unlink($filename);
    }
}
开发者ID:sprytechies,项目名称:loctogo,代码行数:31,代码来源:bootstrap.php

示例8: _log

function _log($message, $style = 'default')
{
    date_default_timezone_set('Europe/Kiev');
    $output = str_pad(getmypid(), 7, ':') . ' |%| ' . date('Y-m-d H:i:s') . ' :: ' . $message . "\n";
    if ($style == 'title') {
        $output = "\n\n" . $output;
    }
    $args = shell_parameters();
    if (!is_dir(log_path())) {
        mkdir(log_path());
    }
    if ($style == 'red') {
        $log_file = isset($args['log']) ? $args['log'] : log_path() . '/log.txt';
        file_put_contents($log_file, $output, FILE_APPEND);
    }
    if ($style == 'red') {
        //echo "\x07\x07\x07\x07\x07\x07\x07\x07\x07";
        $output = "[0;31m" . $output . "[0m";
    } elseif ($style == 'yellow') {
        $output = "[1;33m" . $output . "[0m";
    } elseif ($style == 'green') {
        $output = "[0;32m" . $output . "[0m";
    } elseif ($style == 'title') {
        $output = "[1m" . $output . "[0m";
    }
    print $output;
}
开发者ID:RadaData,项目名称:lawgrabber,代码行数:27,代码来源:helpers.php

示例9: purge

function purge()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pidtime = "/etc/artica-postfix/pids/exec.suricata.hourly.purge.time";
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $time = $unix->PROCCESS_TIME_MIN($pid);
        echo "Starting......: " . date("H:i:s") . " [INIT]: Already Artica task running PID {$pid} since {$time}mn\n";
        return;
    }
    @file_put_contents($pidfile, getmypid());
    if (system_is_overloaded()) {
        return;
    }
    $timeExec = $unix->file_time_min($pidtime);
    if ($timeExec < 1440) {
        return;
    }
    @unlink($pidtime);
    @file_put_contents($pidtime, time());
    $q = new postgres_sql();
    $sock = new sockets();
    $SuricataPurge = intval($sock->GET_INFO("SuricataPurge"));
    if ($SuricataPurge == 0) {
        $SuricataPurge = 15;
    }
    $q->QUERY_SQL("DELETE FROM suricata_events WHERE zdate < NOW() - INTERVAL '{$SuricataPurge} days'");
}
开发者ID:articatech,项目名称:artica,代码行数:29,代码来源:exec.suricata.hourly.php

示例10: start

 /**
  * @param string $router
  * @param array $env
  * @return UrlScript
  * @throws \RuntimeException
  */
 public function start($router, $env = array())
 {
     $this->slaughter();
     static $port;
     if ($port === NULL) {
         do {
             $port = rand(8000, 10000);
             if (isset($lock)) {
                 @fclose($lock);
             }
             $lock = fopen(dirname(TEMP_DIR) . '/http-server-' . $port . '.lock', 'w');
         } while (!flock($lock, LOCK_EX | LOCK_NB, $wouldBlock) || $wouldBlock);
     }
     $ini = NULL;
     if (($pid = getmypid()) && ($myprocess = `ps -ww -fp {$pid}`)) {
         $fullArgs = preg_split('~[ \\t]+~', explode("\n", $myprocess)[1], 8)[7];
         if (preg_match('~\\s\\-c\\s(?P<ini>[^ \\t]+)\\s~i', $fullArgs, $m)) {
             $ini = '-c ' . $m['ini'] . ' -n';
         }
     }
     $executable = new PhpExecutableFinder();
     $cmd = sprintf('%s %s -d register_argc_argv=on -t %s -S %s:%d %s', escapeshellcmd($executable->find()), $ini, escapeshellarg(dirname($router)), $ip = '127.0.0.1', $port, escapeshellarg($router));
     if (!is_resource($this->process = proc_open($cmd, self::$spec, $this->pipes, dirname($router), $env))) {
         throw new HttpServerException("Could not execute: `{$cmd}`");
     }
     sleep(1);
     // give him some time to boot up
     $status = proc_get_status($this->process);
     if (!$status['running']) {
         throw new HttpServerException("Failed to start php server: " . stream_get_contents($this->pipes[2]));
     }
     $this->url = new UrlScript('http://' . $ip . ':' . $port);
     return $this->getUrl();
 }
开发者ID:kdyby,项目名称:selenium,代码行数:40,代码来源:HttpServer.php

示例11: extract

 /**
  * @param string $destDir
  * @throws Exception on bogus files
  */
 public function extract($destDir)
 {
     $zip = $this->openArchive();
     // First pass: validate but don't save anything to disk.
     // Any errors will trip an exception.
     $this->traverseArchive($zip);
     // Second pass: now that we know we're good, actually extract!
     $tmpDir = $destDir . '.tmp' . getmypid();
     $this->traverseArchive($zip, $tmpDir);
     $zip->close();
     if (file_exists($destDir)) {
         $killDir = $tmpDir . '.old';
         $this->quiet();
         $ok = rename($destDir, $killDir);
         $this->loud();
         if (!$ok) {
             common_log(LOG_ERR, "Could not move old custom theme from {$destDir} to {$killDir}");
             // TRANS: Server exception thrown when saving an uploaded theme after decompressing it fails.
             throw new ServerException(_('Failed saving theme.'));
         }
     } else {
         $killDir = false;
     }
     $this->quiet();
     $ok = rename($tmpDir, $destDir);
     $this->loud();
     if (!$ok) {
         common_log(LOG_ERR, "Could not move saved theme from {$tmpDir} to {$destDir}");
         // TRANS: Server exception thrown when saving an uploaded theme after decompressing it fails.
         throw new ServerException(_('Failed saving theme.'));
     }
     if ($killDir) {
         $this->recursiveRmdir($killDir);
     }
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:39,代码来源:themeuploader.php

示例12: log

 /**
  *	ログを出力する
  *
  *	@access	public
  *	@param	int		$level		ログレベル(LOG_DEBUG, LOG_NOTICE...)
  *	@param	string	$message	ログメッセージ(+引数)
  */
 function log($level, $message)
 {
     if ($this->fp == null) {
         return;
     }
     $prefix = strftime('%Y/%m/%d %H:%M:%S ') . $this->ident;
     if ($this->option & LOG_PID) {
         $prefix .= sprintf('[%d]', getmypid());
     }
     $prefix .= sprintf('(%s): ', $this->_getLogLevelName($level));
     if ($this->option & (LOG_FUNCTION | LOG_POS)) {
         $tmp = "";
         $bt = $this->_getBacktrace();
         if ($bt && $this->option & LOG_FUNCTION && $bt['function']) {
             $tmp .= $bt['function'];
         }
         if ($bt && $this->option & LOG_POS && $bt['pos']) {
             $tmp .= $tmp ? sprintf('(%s)', $bt['pos']) : $bt['pos'];
         }
         if ($tmp) {
             $prefix .= $tmp . ": ";
         }
     }
     fwrite($this->fp, $prefix . $message . "\n");
     return $prefix . $message;
 }
开发者ID:BackupTheBerlios,项目名称:delphinus-svn,代码行数:33,代码来源:Ethna_LogWriter_File.php

示例13: testUploadFile

 function testUploadFile()
 {
     global $URL;
     print "starting DupUploadTest\n";
     for ($i = 0; $i < 2; $i++) {
         $loggedIn = $this->mybrowser->get($URL);
         $this->assertTrue($this->myassertText($loggedIn, '/Upload/'));
         $this->assertTrue($this->myassertText($loggedIn, '/From File/'));
         $page = $this->mybrowser->clickLink('From File');
         $this->assertTrue($this->myassertText($page, '/Upload a New File/'));
         $this->assertTrue($this->myassertText($page, '/Select the file to upload:/'));
         /* select Testing folder, filename based on pid */
         $id = $this->getFolderId('Basic-Testing', $page, 'folder');
         $this->assertTrue($this->mybrowser->setField('folder', $id));
         $this->assertTrue($this->mybrowser->setField('getfile', '/home/fosstester/licenses/Affero-v1.0'));
         $desc = 'File Affero-v1.0 uploaded by test UploadFileTest into Testing folder';
         $this->assertTrue($this->mybrowser->setField('description', "{$desc}"));
         $id = getmypid();
         $upload_name = 'TestUploadFile-' . "{$id}";
         $this->assertTrue($this->mybrowser->setField('name', $upload_name));
         /* we won't select any agents this time' */
         $page = $this->mybrowser->clickSubmit('Upload');
         $this->assertTrue($page);
         /* On the second try, we SHOULD see Upload added to job queue */
         if ($i == 1) {
             $this->assertTrue($this->myassertText($page, "/The file {$upload_name} has been uploaded/"), "FAIL! A Duplicate Upload was NOT created!\n" . "The phrase, The file {$upload_name} has been uploaded was NOT seen\n");
         } else {
             $this->assertFalse($this->myassertText($page, "/Upload failed/"), "FAIL! Upload Failed?\nPhrase 'Upload failed found\n");
         }
         //print "*********** Page after upload **************\n$page\n";
     }
 }
开发者ID:DanielDobre,项目名称:fossology,代码行数:32,代码来源:DupUploadTest.php

示例14: getInstance

 /**
  * Return an instance of the Mandrill class.
  *
  * @return Mandrill Instance.
  */
 public static function getInstance()
 {
     // Detect when the PID of the current process has changed (from a fork, etc)
     // and force a reconnect to redis.
     $pid = getmypid();
     if (self::$pid !== $pid) {
         self::$mandrill = null;
         self::$pid = $pid;
     }
     if (!is_null(self::$mandrill)) {
         return self::$mandrill;
     }
     foreach (array_keys(self::$config) as $param) {
         if (Environment::get('mandrill.' . $param)) {
             self::$config[$param] = Environment::get('mandrill.' . $param);
         }
     }
     if (!self::$config['apikey']) {
         throw new Exception('missing Mandrill Configuration', 500);
     }
     try {
         self::$mandrill = new Mandrill(self::$config['apikey']);
     } catch (Exception $e) {
         return null;
     }
     return self::$mandrill;
 }
开发者ID:robert-christopher,项目名称:li3_mandrill,代码行数:32,代码来源:Li3Mandrill.php

示例15: create

 static function create($filename, $directory = false, $data = false, $atomic = false)
 {
     $filepath = $filename;
     if ($directory) {
         if (!file_exists($directory)) {
             eZDir::mkdir($directory, false, true);
             //                 eZDebugSetting::writeNotice( 'ezfile-create', "Created directory $directory", 'eZFile::create' );
         }
         $filepath = $directory . '/' . $filename;
     }
     // If atomic creation is needed we will use a temporary
     // file when writing the data, then rename it to the correct path.
     if ($atomic) {
         $realpath = $filepath;
         $dirname = dirname($filepath);
         if (strlen($dirname) != 0) {
             $dirname .= "/";
         }
         $filepath = $dirname . "ezfile-tmp." . md5($filepath . getmypid() . mt_rand());
     }
     $file = fopen($filepath, 'wb');
     if ($file) {
         //             eZDebugSetting::writeNotice( 'ezfile-create', "Created file $filepath", 'eZFile::create' );
         if ($data) {
             fwrite($file, $data);
         }
         fclose($file);
         if ($atomic) {
             eZFile::rename($filepath, $realpath);
         }
         return true;
     }
     //         eZDebugSetting::writeNotice( 'ezfile-create', "Failed creating file $filepath", 'eZFile::create' );
     return false;
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:35,代码来源:ezfile.php


注:本文中的getmypid函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。