array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.dio-fcntl.php', 1 => 'dio_fcntl', ), 'up' => array ( 0 => 'ref.dio.php', 1 => 'Direct IO 函数', ), 'prev' => array ( 0 => 'function.dio-close.php', 1 => 'dio_close', ), 'next' => array ( 0 => 'function.dio-open.php', 1 => 'dio_open', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/dio/functions/dio-fcntl.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4 >= 4.2.0, PHP 5 < 5.1.0)
dio_fcntl — 在 fd 上执行 C 标准库的 fcntl
dio_fcntl() 函数在 fd
文件描述符上执行 cmd
指定的操作。一些命令需要提供额外的 args
参数。
fd
dio_open() 返回的文件描述符。
cmd
可以是以下操作:
args
当 cmd
是 F_SETLK
或 F_SETLLW
时,args
是包含以下键的关联数组:
返回 C 调用的结果。
示例 #1 设置并清除锁
<?php
$fd = dio_open('/dev/ttyS0', O_RDWR);
if (dio_fcntl($fd, F_SETLK, Array("type"=>F_WRLCK)) == -1) {
// the file descriptor appears locked
echo "The lock can not be cleared. It is held by someone else.";
} else {
echo "Lock successfully set/cleared";
}
dio_close($fd);
?>
注意: 此函数未在 Windows 平台下实现。