linux pipe 管道简单例子
来源:互联网 发布:淘宝摇一摇 编辑:程序博客网 时间:2024/05/21 10:50
linux pipe 管道简单例子
//// Created by liyihang on 17-9-25.//#include <sys/wait.h>#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <string.h>int main(int argc, char *argv[]){ int pipe_fd[2]; pid_t child_pid; char pipe_buf; memset(pipe_fd, 0, sizeof(int)*2); if (pipe(pipe_fd)==-1){ printf("open err\n"); return -1; } child_pid=fork(); if (child_pid==-1) { printf("thead err\n"); } if (child_pid==0) { close(pipe_fd[1]); printf("while start\n"); while (read(pipe_fd[0], &pipe_buf, 1)>0) {// write(STDOUT_FILENO, &pipe_buf, 1); printf("read content outs:%s\n", &pipe_buf); } close(pipe_fd[0]); printf("child thead ok\n"); return 0; } else{ close(pipe_fd[0]); write(pipe_fd[1], "h", 1); close(pipe_fd[1]); printf("father thaed ok\n");// wait(NULL); wait(&child_pid); printf("wait thread \n"); return 0; }}
阅读全文
0 0
- linux pipe 管道简单例子
- linux--管道pipe
- Linux 管道(pipe)
- Linux pipe(管道)
- linux管道pipe
- linux管道(pipe)
- linux管道pipe详解
- 【linux】匿名管道pipe
- Linux 管道pipe
- linux管道pipe详解
- linux pipe 无名管道
- linux管道pipe详解
- 使用匿名管道pipe例子
- linux操作系统编程——简单的pipe管道
- linux 管道(linux Pipe与named Pipe)
- Pipe 简单的例子
- Linux C编程 - 管道pipe
- linux之无名管道pipe
- eclipse下载svn,导入项目,并操作
- Batch Normalization 学习笔记
- 设计模式-备忘录模式
- retrofit上传获取文件上传进度
- Android 自定义View(二),点,线的绘制
- linux pipe 管道简单例子
- 用python画散点图
- 冒泡排序
- JAVA跨域问题
- Redis的数据类型及相关操作命令
- 专访微软研究院张正友:从“张氏标定法”到人机交互,20年视觉技术的探索
- 初识Hibernate之关联映射(二)
- JAVA学习笔记——Set集合
- gitlab-ci.yml配置