fcntl函数介绍

来源:互联网 发布:遗传算法简单实例 编辑:程序博客网 时间:2024/06/07 05:41

《朱老师物联网大讲堂》学习笔记 

学习地址:www.zhulaoshi.org


fcntl函数的介绍,

        int fcntl(int fd, int cmd, ... /* arg */ );

是一个多功能的文件管理的工具箱,接收2个参数和一个变参,

fd是操作的文件,cmd是操作的命令,arg是对应cmd的命令参数,


一个常用的cmd,

F_DUPFD()

       F_DUPFD (int)

              Find the lowest numbered available file descriptor greater  than

              or  equal to arg and make it be a copy of fd.  This is different

              from dup2(2), which uses exactly the descriptor specified.


              On success, the new descriptor is returned.


              See dup(2) for further details.


使用fcntl模拟dup2,


0 0
原创粉丝点击