• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP posix_mkfifo函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: __construct

 /**
  * Constructor.
  * @param string $filePath The file that is going to store the pipe.
  * @param bool $isReadMode Indicates if the param is going to be read only
  * @param bool $autoDeletion If it is set during the destruction of the GPhpThreadIntercom instance the pipe file will be also removed.
  */
 public function __construct($filePath, $isReadMode = true, $autoDeletion = false)
 {
     // {{{
     $this->ownerPid = getmypid();
     if (!file_exists($filePath)) {
         if (!posix_mkfifo($filePath, 0644)) {
             $this->success = false;
             return;
         }
     }
     $commChanFd = fopen($filePath, $isReadMode ? 'r+' : 'w+');
     // + mode makes it non blocking too
     if ($commChanFd === false) {
         $this->success = false;
         return;
     }
     if (!stream_set_blocking($commChanFd, false)) {
         $this->success = false;
         fclose($commChanFd);
         if ($autoDeletion) {
             @unlink($filePath);
         }
         return;
     }
     $this->commChanFdArr[] = $commChanFd;
     $this->commFilePath = $filePath;
     $this->autoDeletion = $autoDeletion;
     $this->isReadMode = $isReadMode;
 }
开发者ID:zhgzhg,项目名称:gphpthread,代码行数:35,代码来源:GPhpThread.php


示例2: __construct

 public function __construct($name, $read_cb = null)
 {
     $pipes_folder = JAXL_CWD . '/.jaxl/pipes';
     if (!is_dir($pipes_folder)) {
         mkdir($pipes_folder);
     }
     $this->ev = new JAXLEvent();
     $this->name = $name;
     $this->read_cb = $read_cb;
     $pipe_path = $this->get_pipe_file_path();
     if (!file_exists($pipe_path)) {
         posix_mkfifo($pipe_path, $this->perm);
         $this->fd = fopen($pipe_path, 'r+');
         if (!$this->fd) {
             _error("unable to open pipe");
         } else {
             _debug("pipe opened using path {$pipe_path}");
             _notice("Usage: \$ echo 'Hello World!' > {$pipe_path}");
             $this->client = new JAXLSocketClient();
             $this->client->connect($this->fd);
             $this->client->set_callback(array(&$this, 'on_data'));
         }
     } else {
         _error("pipe with name {$name} already exists");
     }
 }
开发者ID:lcandida,项目名称:push-message-serie-web,代码行数:26,代码来源:jaxl_pipe.php


示例3: __construct

 /**
  * @param string $name
  * @param callable $read_cb TODO: Currently not used
  */
 public function __construct($name, $read_cb = null)
 {
     // TODO: see JAXL->cfg['priv_dir']
     $this->pipes_folder = getcwd() . '/.jaxl/pipes';
     if (!is_dir($this->pipes_folder)) {
         mkdir($this->pipes_folder, 0777, true);
     }
     $this->ev = new JAXLEvent();
     $this->name = $name;
     // TODO: If someone's need the read callback and extends the JAXLPipe
     // to obtain it, one can't because this property is private.
     $this->read_cb = $read_cb;
     $pipe_path = $this->get_pipe_file_path();
     if (!file_exists($pipe_path)) {
         posix_mkfifo($pipe_path, $this->perm);
         $this->fd = fopen($pipe_path, 'r+');
         if (!$this->fd) {
             JAXLLogger::error("unable to open pipe");
         } else {
             JAXLLogger::debug("pipe opened using path {$pipe_path}");
             JAXLLogger::notice("Usage: \$ echo 'Hello World!' > {$pipe_path}");
             $this->client = new JAXLSocketClient();
             $this->client->connect($this->fd);
             $this->client->set_callback(array(&$this, 'on_data'));
         }
     } else {
         JAXLLogger::error("pipe with name {$name} already exists");
     }
 }
开发者ID:jaxl,项目名称:JAXL,代码行数:33,代码来源:jaxl_pipe.php


示例4: __construct

 public function __construct($file)
 {
     $this->file = $file;
     if (!file_exists($file)) {
         posix_mkfifo($file, 0700);
     }
 }
开发者ID:radean0909,项目名称:phpianobar,代码行数:7,代码来源:FifoAdapter.php


示例5: __construct

 /**
  * Constructor.
  *
  * @param Master  $master The master object
  * @param integer $pid    The child process id or null if this is the child
  *
  * @throws \Exception
  * @throws \RuntimeException
  */
 public function __construct(Master $master, $pid = null)
 {
     $this->master = $master;
     $directions = array('up', 'down');
     if (null === $pid) {
         // child
         $pid = posix_getpid();
         $pPid = posix_getppid();
         $modes = array('write', 'read');
     } else {
         // parent
         $pPid = null;
         $modes = array('read', 'write');
     }
     $this->pid = $pid;
     $this->ppid = $pPid;
     foreach (array_combine($directions, $modes) as $direction => $mode) {
         $fifo = $this->getPath($direction);
         if (!file_exists($fifo) && !posix_mkfifo($fifo, 0600) && 17 !== ($error = posix_get_last_error())) {
             throw new \Exception(sprintf('Error while creating FIFO: %s (%d)', posix_strerror($error), $error));
         }
         $this->{$mode} = fopen($fifo, $mode[0]);
         if (false === ($this->{$mode} = fopen($fifo, $mode[0]))) {
             throw new \RuntimeException(sprintf('Unable to open %s FIFO.', $mode));
         }
     }
 }
开发者ID:gcds,项目名称:morker,代码行数:36,代码来源:Fifo.php


示例6: open

 public function open($fifoFile)
 {
     $this->fifoFile = $fifoFile;
     $dir = pathinfo($this->fifoFile, PATHINFO_DIRNAME);
     umask(0);
     $this->selfCreated = false;
     if (!is_dir($dir)) {
         if (!mkdir($dir, 0777, true)) {
             throw new \Exception("Could not create directory {$dir}");
         }
     }
     // If pipe was not create on another side
     if (!file_exists($this->fifoFile)) {
         if (!posix_mkfifo($this->fifoFile, 0777)) {
             throw new \Exception("Could not create {$this->fifoFile}: " . posix_strerror(posix_get_last_error()));
         } else {
             $this->selfCreated = true;
         }
     }
     log::debug("Creating stream for {$this->fifoFile}");
     $stream = fopen($this->fifoFile, "c+");
     log::debug("Stream {$stream} = {$this->fifoFile}");
     $this->valid = (bool) $stream;
     parent::open($stream);
     $this->setBlocking(false);
 }
开发者ID:a13k5and3r,项目名称:Stream,代码行数:26,代码来源:NamedPipe.php


示例7: create

 /**
  * Create the file if needed
  *
  * @return Pipe
  */
 public function create()
 {
     if (!is_file($this->name)) {
         return;
     }
     posix_mkfifo($this->name, 0777);
     return $this;
 }
开发者ID:pedrotroller,项目名称:phpetroleum,代码行数:13,代码来源:Pipe.php


示例8: init_pipes

 static function init_pipes()
 {
     for ($i = 1; $i <= Config::$queue_number; $i++) {
         $queue_file = Config::$queue_dir . "/websnap_queue_{$i}";
         if (!file_exists($queue_file)) {
             posix_mkfifo($queue_file, 0644);
         }
     }
 }
开发者ID:rhalff,项目名称:Websnapit,代码行数:9,代码来源:util.php


示例9: __construct

 public function __construct($pathname, $mod = 0660)
 {
     if (!is_file($pathname)) {
         if (!posix_mkfifo($pathname, $mod)) {
             // throw
         }
     }
     $this->pathname = $pathname;
 }
开发者ID:panlatent,项目名称:aurora,代码行数:9,代码来源:Pipe.php


示例10: __construct

 /**
  * @param string $filename fifo filename
  * @param int $mode
  * @param bool $block if blocking
  */
 public function __construct($filename = '/tmp/simple-fork.pipe', $mode = 0666, $block = false)
 {
     if (!file_exists($filename) && !posix_mkfifo($filename, $mode)) {
         throw new \RuntimeException("create pipe failed");
     }
     if (filetype($filename) != "fifo") {
         throw new \RuntimeException("file exists and it is not a fifo file");
     }
     $this->filename = $filename;
     $this->block = $block;
 }
开发者ID:asuper114,项目名称:simple-fork-php,代码行数:16,代码来源:Pipe.php


示例11: __construct

 public function __construct($port = 4444, $address = '127.0.0.1')
 {
     parent::__construct($port, $address);
     $this->pid = posix_getpid();
     if (!file_exists(self::PIPENAME)) {
         umask(0);
         if (!posix_mkfifo(self::PIPENAME, 0666)) {
             die('Cant create a pipe: "' . self::PIPENAME . '"');
         }
     }
     $this->pipe = fopen(self::PIPENAME, 'r+');
 }
开发者ID:skylmsgq,项目名称:DWMS,代码行数:12,代码来源:SocketServerBroadcast.php


示例12: __construct

 /**
  * Create a new pipeline.
  */
 public function __construct()
 {
     $tmp_path = tempnam(sys_get_temp_dir(), "spawn.");
     // Initialise FIFO pipes.
     $this->request_path = $tmp_path . '.i';
     $this->response_path = $tmp_path . '.o';
     if (!file_exists($this->request_path)) {
         posix_mkfifo($this->request_path, 0644);
     }
     if (!file_exists($this->response_path)) {
         posix_mkfifo($this->response_path, 0644);
     }
 }
开发者ID:rthrfrd,项目名称:spawn.php,代码行数:16,代码来源:Pipeline.php


示例13: createStream

 public function createStream()
 {
     if ('Linux' !== PHP_OS) {
         return parent::createStream();
     }
     $this->fifoPath = tempnam(sys_get_temp_dir(), 'react-');
     unlink($this->fifoPath);
     // Use a FIFO on linux to get around lack of support for disk-based file
     // descriptors when using the EPOLL back-end.
     posix_mkfifo($this->fifoPath, 0600);
     $stream = fopen($this->fifoPath, 'r+');
     return $stream;
 }
开发者ID:ondrejmirtes,项目名称:event-loop,代码行数:13,代码来源:LibEventLoopTest.php


示例14: createFifo

 /**
  * 创建fifo
  * @return [type] [description]
  */
 protected function createFifo()
 {
     if (file_exists($this->name) && filetype($this->name) != 'fifo') {
         copy($this->name, $this->name . '.backup');
         unlink($this->name);
     }
     if (!file_exists($this->name) && true !== posix_mkfifo($this->name, $this->mode)) {
         throw new \Exception('create fifo fail');
     }
     if (filetype($this->name) != 'fifo') {
         throw new \Exception('fifo type error');
     }
 }
开发者ID:chenchun0629,项目名称:fifo,代码行数:17,代码来源:Fifo.php


示例15: _pipeInit

 /** Initialize the named pipe
 		@param pipefile	Name of the new named pipe to create
 		@param mode	Numeric permission indicator for the new pipe
 	*/
 function _pipeInit($pipefile, $mode)
 {
     if (!file_exists($pipefile)) {
         // create the pipe
         umask(0);
         posix_mkfifo($pipefile, $mode);
     }
     // save the pipe to instance var
     $this->pipe = fopen($pipefile, "r+");
     // turn off blocking
     stream_set_blocking($this->pipe, 0);
     //fwrite($this->pipe, "cfDebug Init\n\n");
 }
开发者ID:xtha,项目名称:salt,代码行数:17,代码来源:profiler.php


示例16: __construct

 function __construct($fifoPath, $mode = 0666)
 {
     //posix_getpid 返回进程ID号
     // $fifoPath = "/home//$name.".posix_getpid();
     if (!file_exists($fifoPath)) {
         if (!posix_mkfifo($fifoPath, $mode)) {
             error('create new pipe ($name) error.');
             return false;
         }
     } else {
         error("pipe ({$name}) has exist.");
         return false;
     }
     $this->fifoPath = $fifoPath;
 }
开发者ID:pengzhengrong,项目名称:account,代码行数:15,代码来源:tourism_wr.class.php


示例17: __construct

 public function __construct($file, $create = true)
 {
     $this->file = $file;
     if (!$this->exists() && $create) {
         touch($this->file);
         posix_mkfifo($this->file, 0666);
         $this->creator = true;
         $this->fh = fopen($this->file, "r+");
     } else {
         if ($this->exists()) {
             $this->fh = fopen($this->file, "r+");
         } else {
             throw new \Exception("Could not open FIFO for reading: Node does not exist.");
         }
     }
     stream_set_blocking($this->fh, 0);
 }
开发者ID:noccy80,项目名称:cherryphp,代码行数:17,代码来源:namedpipe.php


示例18: __construct

 public function __construct($name, $perm = 0600)
 {
     $this->name = $name;
     $this->perm = $perm;
     $pipe_path = $this->get_pipe_file_path();
     if (!file_exists($pipe_path)) {
         posix_mkfifo($pipe_path, $this->perm);
         $this->fd = fopen($pipe_path, 'r+');
         if (!$this->fd) {
             _error("unable to open pipe");
         }
         stream_set_blocking($this->fd, false);
         // watch for incoming data on pipe
         JAXLLoop::watch($this->fd, array('read' => array(&$this, 'on_read_ready')));
     } else {
         _error("pipe with name {$name} already exists");
     }
 }
开发者ID:nimdraugsael,项目名称:furiko-server,代码行数:18,代码来源:jaxl_pipe.php


示例19: runCommandWithStdErr

 /**
  * Runs the command and returns the command output and the separated STDERR in the outgoing parameter.
  *
  * Uses the "system.commandOutputHelper.work.path" config, what is describes the directory where the temporary
  * file pointer will be added. (default => /tmp)
  *
  * @param CommandExecutor $command   The command executor object.
  * @param string          $stdErr    The error messages [Outgoing]
  *
  * @return \YapepBase\Shell\CommandOutput   The output of the command.
  * @throws \Exception
  */
 public function runCommandWithStdErr(CommandExecutor $command, &$stdErr)
 {
     $dir = Config::getInstance()->get('system.commandOutputHelper.work.path', '/tmp');
     $pipePath = tempnam($dir, 'stderr-');
     $fileHandler = Application::getInstance()->getDiContainer()->getFileHandler();
     try {
         posix_mkfifo($pipePath, 0755);
         $command->setOutputRedirection(CommandExecutor::OUTPUT_REDIRECT_STDERR, $pipePath);
         $result = $command->run();
         $stdErr = $fileHandler->getAsString($pipePath);
         $fileHandler->remove($pipePath);
     } catch (\Exception $e) {
         if ($fileHandler->checkIsPathExists($pipePath)) {
             $fileHandler->remove($pipePath);
         }
         throw $e;
     }
     return $result;
 }
开发者ID:szeber,项目名称:yapep_base,代码行数:31,代码来源:CommandOutputHelper.php


示例20: ensureFifo

 /**
  * Ensure the fifo is created.
  */
 private function ensureFifo()
 {
     if (file_exists($this->fileName)) {
         $type = filetype($this->fileName);
         if ($type != "fifo") {
             throw new Exception("File already exists, but it is not a fifo");
         }
         return;
     }
     if (function_exists("posix_mkfifo")) {
         if (!posix_mkfifo($this->fileName, 0644)) {
             throw new Exception("Unable to create fifo using posix_mkfifo");
         }
         return;
     }
     exec("/usr/bin/mkfifo " . escapeshellarg($this->fileName), $ret, $err);
     if ($err) {
         throw new Exception("Unable to create fifo using exec(mkfifo)");
     }
 }
开发者ID:limikael,项目名称:wp-crypto-accounts,代码行数:23,代码来源:PubSub.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP posix_seteuid函数代码示例发布时间:2022-05-15
下一篇:
PHP posix_kill函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap