2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > 《Linux系统调用:文件控制操作 fcntl》

《Linux系统调用:文件控制操作 fcntl》

时间:2021-09-13 09:00:04

相关推荐

《Linux系统调用:文件控制操作 fcntl》

一、接口介绍

fcntl()系统调用对一个打开的文件描述符执行一系列控制操作。

#include <unistd.h>#include <fcntl.h>int fcntl(int fd, int cmd, ... /* arg */ );参数:fd: open 打开的文件描述符cmd: 太多,请看参考文档F_GETFDF_SETFD (int) // 这类带参数的都是要用到argF_GETLKF_SETLK (struct flock *)F_GETFLF_SETFL (int)...arg:具体要看cmd 是否需要 所以由上面可以看出,fcntl其实相当于有三种:int fcntl(int fd, int cmd); int fcntl(int fd, int cmd, long arg); int fcntl(int fd, int cmd, struct flock *lock);返回值:For a successful call, the return value depends on the operation:F_DUPFD The new descriptor.F_GETFD Value of file descriptor flags.F_GETFL Value of file status flags.F_GETLEASEType of lease held on file descriptor.

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。