linux 进程间通信fifo_write
2015-12-11 00:00
190 查看
hyh@hyh-OptiPlex-9020:~/git/hyh_home/1512_home/应用程序设计/进程通讯$ cat fifo_write.c
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define FIFO_SERVER "./myfifo"
main(int argc,char** argv)
{
int fd;
char w_buf[100];
int nwrite;
fd=open(FIFO_SERVER,O_WRONLY|O_NONBLOCK,0);
if(argc==1)
{
printf("Please send something\n");
exit(-1);
}
strcpy(w_buf,argv[1]);
if((nwrite=write(fd,w_buf,100))==-1)
{
if(errno==EAGAIN)
printf("The FIFO has not been read yet.Please try later\n");
}
else
printf("write %s to the FIFO\n",w_buf);
}
hyh@hyh-OptiPlex-9020:~/git/hyh_home/1512_home/应用程序设计/进程通讯$
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define FIFO_SERVER "./myfifo"
main(int argc,char** argv)
{
int fd;
char w_buf[100];
int nwrite;
fd=open(FIFO_SERVER,O_WRONLY|O_NONBLOCK,0);
if(argc==1)
{
printf("Please send something\n");
exit(-1);
}
strcpy(w_buf,argv[1]);
if((nwrite=write(fd,w_buf,100))==-1)
{
if(errno==EAGAIN)
printf("The FIFO has not been read yet.Please try later\n");
}
else
printf("write %s to the FIFO\n",w_buf);
}
hyh@hyh-OptiPlex-9020:~/git/hyh_home/1512_home/应用程序设计/进程通讯$
相关文章推荐
- Linux 技巧:让进程在后台可靠运行的几种方法
- linux下零拷贝技术
- Linux输入命令出错时快速编辑指令
- [Linux]crontab 创建定时任务
- Linux ixgbe 10G intel 网卡数据包处理流程
- linux目录权限及目录配置
- Linux:主机linux内核版本升级实验
- CentOS 7.0 安装Chrome 浏览器的方法
- Linux学习之简单指令二
- Linux内核的namespace机制分析
- Linux进程间通信机制
- Install PHP 7.0 (phpng) on CentOS & RedHat
- 在虚拟机中安装CentOS却无法上网的解决方法
- Linux基础5 命令的帮助
- 第二章 Linux系统安装 - VMware虚拟机安装、卸载与使用
- CentOS 6.5下搭建hadoop 2.6.0集群(一):安装配置JDK
- CentOS6.4下Mysql数据库的安装与配置
- linux下命令取IP地址的多种方法
- 清理linux内存cache
- linux socket 编程顶尖教程