对于指定的描述符打印文件标志
2016-12-23 21:28
274 查看
#include <stdio.h> #include <stdlib.h> #include <fcntl.h> int main(int argc,char * argv[]){ int val; if(argc!=2){ printf("usage:a.out <descriptor#>"); } if((val=fcntl(atoi(argv[1]),F_GETFL,0))<0){ printf("fcntl error for fd %d",atoi(argv[1])); } switch(val &O_ACCMODE){ case O_RDONLY: printf("read only"); break; case O_WRONLY: printf("write only"); break; case O_RDWR: printf("read write"); break; default : printf("unknown access mode"); } if (val & O_APPEND){ printf(",append"); } if(val & O_NONBLOCK){ printf(",nonblocking"); } #if defined(O_SYNC) if(val & O_SYNC) printf(",synchronous writes"); #endif #if !defined(_POSIX_C_SOURCE) && defined(O_FSYNC) if(val & O_FSYNC) printf(",synchronous writes") #endif putchar('\n'); exit(0); }
相关文章推荐
- APUE-3.4 对于指定的描述符打印文件标志
- 3.4 对于指定的描述符打印文件标志
- APUE 3-11 对于指定的描述符打印文件标志
- 程序3-4 对指定的描述符打印文件标志
- APUE-用fcntl函数对指定的描述符打印和开启文件标志
- 《Unix环境高级编程》:打印指定的描述符的文件标志
- 采用多线程和生产者消费者模式来实现对于一个目录以及所有子目录下的文件内容的搜索,打印出包含指定关键字的行.
- PHP遍历并打印指定目录下所有文件
- PHP遍历并打印指定目录下所有文件实例
- Java实现对于文件的多种操作,复制、删除、重命名、剪切文件、统计指定类型文件数等10个功能
- printk信息打印到指定文件 终端 网络
- 打印指定目录下所有文件
- C# 直接打印指定路径文件 + 可选择指定打印机
- 如何得到指定文件的公司名称,文件描述,内部名称,合法版权,原始文件名,产品名称,产品版本等一系列信息
- gerp(1):查找文件中指定的字符串,并打印该行
- 鸟哥linux中对于文件系统的描述
- tomcat配置log4j打印输出日志到指定文件
- C#使用指定打印机打印Word,Excel等Office文件和打印PDF文件的代码
- Java--对于 class文件进行加密 然后通过我们自己写的类加载器进行加载指定类
- 嵌入式 简单的读取文件并打印指定字符串的值