Liunx_4.4_有名管道
来源:互联网 发布:2016access数据库教程 编辑:程序博客网 时间:2024/06/05 20:09
(1) 有名管道:
(2) FIFO文件对比普通文件
5.2创建有名管道
5.2.1 函数名
mkfifo
5.2.2 函数原形
int mkfifo(const char*pathname,mode_t mode)
5.2.3 函数功能
创建fifo文件(有名管道)
5.2.4 所属头文件
#include <sys/types.h>
#include <sys/stat.h>
5.2.5 返回值
成功:0
失败:-1
5.2.6 参数说明
pathname:要创建的fifo文件的名字(带路径)
mode:创建的fifo文件的访问权限
5.3删除有名管道
5.3.1 函数名
unlink
5.3.2 函数原形
int unlink(const char*pathname)
5.3.3 函数功能
删除文件
5.3.4 所属头文件
#include <unistd.h>
5.3.5 返回值
成功:0
失败:-1
5.3.6 参数说明
pathname:用来指明要删除的文件名字(含路径)
程序实例:
fifo_write.c文件
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main(void)
{
int fd;
int ret;
/*1. create fifo file*/
mkfifo("/tmp/myfifo",0666);
/*2. open filo file*/
fd = open("/tmp/myfifo",O_WRONLY);
/*3. write date to fifo file */
ret = write(fd,"hello fifo",11);
close(fd);
return 0;
}
fifo_read.c文件:
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
int main(void)
{
char c_buf[15];
int fd;
fd = open("/tmp/myfifo",O_RDONLY);
read(fd, c_buf,11);
printf("read %s\n",c_buf);
close(fd);
unlink("/tmp/myfifo");
return 0;
}
- Liunx_4.4_有名管道
- 4 有名管道1
- 进程间的通讯方式_管道(有名管道)
- 有名管道
- 有名管道
- 有名管道
- 有名管道
- 有名管道
- 有名管道
- 有名管道
- 有名管道
- 有名管道
- 有名管道
- 有名管道
- 有名管道
- 有名管道
- 有名管道
- 有名管道
- Mafefile的FizzzBuzz
- [BZOJ1715][Usaco2006 Dec]Wormholes 虫洞
- cocos2dx项目打包APK环境安装
- 从线性回归谈到岭回归lasso回归再到结构风险最小化和参数缩减
- android 监听EditText 的变化
- Liunx_4.4_有名管道
- poj 1731 Orders
- jquert结合原生javascript实现的checkbox全选与全不选
- 判断两个单链表是否相交
- android中string.xml中%1$s、%1$d等的用法
- Android 项目中文件夹的作用(初识)
- Overview of Gazebo Plugins
- Android Scroller类的详细分析
- 给定入栈序列1到n,输出所有可能的出栈序列