【C语言】【unix c】如何创建无名管道

xiaoxiao2021-02-27  205

使用管道系统提供了 pipe(2) #include <unistd.h> int pipe(int pipefd[2]); 功能:创建一个管道,单向的 参数: pipefd:用于返回管道的两端 [0]:指向管道的读端 [1]:指向管道的写端 返回值: 成功 0 失败 -1 errno被设置 #include <unistd.h> //创建管道 int fd[2]; int pc = pipe(fd); //判断是否创建成功 if(pc == -1) { perror("pipe"); return -1; }
转载请注明原文地址: https://www.6miu.com/read-14324.html

最新回复(0)