文件I/O-008.fcntl返回文件标志并解析打印标志
来源:互联网 发布:淘宝商家客服投诉电话 编辑:程序博客网 时间:2024/06/06 19:15
/*fcntl()返回文件标志并解析打印文件标志*/#include <stdio.h>#include <stdlib.h>#include <fcntl.h>#include <unistd.h>#include <string.h>int main(int argc,char const *argv[]){ int val;val=fcntl(atoi(argv[1]),F_GETFL,0);if(val == -1){ printf("fcntl erro\n");}switch(val & O_ACCMODE)//O_ACCMODE 003{case O_RDONLY:printf("read only");break;//O_RDONLY 000case O_WRONLY:printf("read only");break;//O_WRONLY 001case O_RDWR:printf("read only");break;//O_RDWR 002default:printf("unknown access mode");}if(val & O_APPEND)//O_APPEND 2000{ printf(",append");}if(val & O_NONBLOCK)//O_NONBLOCK 4000{ printf(",nonblock");}putchar('\n');exit(0);}/*./a.out 0read only./a.out 2read only./a.out 1read only./a.out 0 < /dev/ttyread only./a.out 1 > temp.foocat temp.fooread only./a.out 2 2>>temp.fooread only,append./a.out 5 5<>temp.fooread only*/
0 0
- 文件I/O-008.fcntl返回文件标志并解析打印标志
- Linux -- fcntl修改文件状态标志
- APUE-用fcntl函数对指定的描述符打印和开启文件标志
- fcntl获取和修改文件打开状态标志
- C语言之文件编程标志I/O库(2)
- 简单文件I/O编程之fcntl
- 文件I/O之fcntl函数
- 关于文件结束标志
- 各类文件头标志
- 文件描述符标志
- 文件头标志
- 文件头标志
- 文件I/O实践(3) --文件共享与fcntl
- 文件I/O实践(3) --文件共享与fcntl
- 文件I/O实践(3) --文件共享与fcntl
- 文件I/O实践(3) --文件共享与fcntl
- APUE-3.4 对于指定的描述符打印文件标志
- 对于指定的描述符打印文件标志
- 文件I/O-007.argc,argv[]
- Apache mina2 用户指南(三)IO服务
- Markdown的使用之一:文本格式化
- C#单例模式的 几种写法
- dart资料
- 文件I/O-008.fcntl返回文件标志并解析打印标志
- Hadoop1.2.1开发环境搭建
- #ifdef #ifndef #if #include #line #pragma #define命令
- CodeForces-718A Efim and Strange Grade(模拟)
- 关于Visual Studio c#程序.netframework错误的解决记录
- SwipeRefreshLayout详解和自定义加载更多
- Google's Neural Machine Translation System
- 文件I/O-009.set_fl()的实现
- 微信小应用,又一大神,音乐播放器