首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

unix 中的fcntl()函数解决方案

2012-05-03 
unix 中的fcntl()函数最近在看unix高级编程那本书,fcntl(fd1, F_GETFL,0)书上说是返回the file descriptor

unix 中的fcntl()函数
最近在看unix高级编程那本书,
fcntl(fd1, F_GETFL,0)
书上说是返回the file descriptor flags
fcntl(fd1, F_GETFD,0)
返回the file status flags
请问这两者有什么区别啊?

[解决办法]
希望下面的信息能帮到你
File descriptor flags
The following commands manipulate the flags associated with a file descriptor. Currently, only one such flag is defined: FD_CLOEXEC, the close-on-exec
flag. If the FD_CLOEXEC bit is 0, the file descriptor will remain open across an execve(2), otherwise it will be closed.

File status flags
Each open file description has certain associated status flags, initialized by open(2) and possibly modified by fcntl(). Duplicated file descriptors
(made with dup(2), fcntl(F_DUPFD), fork(2), etc.) refer to the same open file description, and thus share the same file status flags.
F_SETFL (long)
Set the file status flags to the value specified by arg. File access mode (O_RDONLY, O_WRONLY, O_RDWR) and file creation flags (i.e., O_CREAT,
O_EXCL, O_NOCTTY, O_TRUNC) in arg are ignored. On Linux this command can only change the O_APPEND, O_ASYNC, O_DIRECT, O_NOATIME, and O_NONBLOCK
flags.

[解决办法]
该函数调用的返回值是依赖其参数选项,
F_DUPFD 返回值为:The new descriptor.
F_GETFD 返回值为:Value of flags.
F_GETFL 返回值为:Value of flags.
...

热点排行