程序3-5 对一个文件描述符打开一个或多个文件状态标志
2014-04-25 22:09
239 查看
//http://blog.chinaunix.net/uid-24549279-id-71355.html /* ============================================================================ Name : test.c Author : blank Version : Copyright : Your copyright notice Description : 程序3-5 对一个文件描述符打开一个或多个文件状态标志 ============================================================================ */ #include <stdio.h> #include <unistd.h> #include <fcntl.h> #include "ourhdr.h" /* * flags are file status flags to turn on */ void set_f1(int fd, int flags){ int val; if ((val = fcntl(fd, F_GETFD, 0)) < 0){ err_sys("fcntl F_GETFD error\n"); } // turn on val |= flags; if (fcntl(fd, F_SETFD, val) < 0){ err_quit("fcntl F_SETFL error\n"); } } /* * flags are file status flags to turn off */ void del_f1(int fd, int flags){ int val; if ((val = fcntl(fd, F_GETFD, 0)) < 0){ err_sys("fcntl F_GETFD error\n"); } // turn off val &= ~flags; if (fcntl(fd, F_SETFD, val) < 0){ err_quit("fcntl F_SETFL error\n"); } }
相关文章推荐
- 3.5 对一个文件描述符打开一个或多个文件状态标志
- [每天一个Linux小技巧] 巧用strace查找程序打开的文件
- 程序4-5 打开一个文件,然后unlink
- MFC如何实现打开一个文件,就像安装完某个程序然后弹出一个readme.txt一样?
- 背水一战 Windows 10 (98) - 关联启动: 使用外部程序打开一个文件, 使用外部程序打开一个 Uri
- 练习2-3:编一个程序用来打开文件并统计文件中以空格隔开的单词数目
- 作业: 1.创建一个窗口程序(JFrame),标题栏起名为“浏览器”,有一个菜单条,有“文件”、“编辑”、“查看”3个菜单。“文件”菜单有两个菜单项,一项是“打开”,一项是“保存”,“打开”项做成子菜
- 重新想象 Windows 8 Store Apps (33) - 关联启动: 使用外部程序打开一个文件或uri, 关联指定的文件类型或协议
- 一个打开并检查输入文件的程序
- windows server 2008下无法用程序打开一个xls文件问题
- matlab双击.m文件另外打开一个matlab程序的问题
- C#双击文件只让同一个程序打开文件
- 为win7下的无后缀文件设置一个默认打开程序
- VC 实现当拖动一个文件到程序的图标上时,程序自动启动并打开该文件
- 一个可以打开常用程序文件的菜单
- 编写一个程序,它打开一个文本文件,逐个字符地读取该文件,直到到达文件末尾,然后指出该文件中包含多少个字符
- .创建一个窗口程序(JFrame),标题栏起名为“浏览器”,有一个菜单条,有“文件”、“编辑”、“查看”3个菜单。“文件”菜单有两个菜单项,一项是“打开”,一项是“保存”,“打开”项做成子菜单,有两个
- C#双击文件只让同一个程序打开文件
- 与众不同 windows phone (38) - 8.0 关联启动: 使用外部程序打开一个文件或URI, 关联指定的文件类型或协议
- 编写两个不同的可执行程序,一个打开文件,一个读文件