随笔小屋 Logo
首页
瞬间
反馈
随笔小屋 Logo
首页 瞬间 反馈
  1. 首页
  2. linux
  3. 管道通信

管道通信

  • linux
  • 发布于 2025-10-11
  • 343 次阅读
flor
flor

有名管道(不同进程间通信)

#include <sys/stat.h>
int mkfifo(char const* pathname, mode_t mode);
功能:创建有名管道
参数:
pathname: 有名管道名,即管道文件的路径。
mode: 权限模式。
返回值:成功返回0,失败返回-1
  1. 创建 mkfifo

  2. 打开 open

  3. 读写 read/write

  4. 关闭 close

  5. 删除 unlink

无名管道(父子进程等相同文件描述符表间通信)

#include <unistd.h>
int pipe(int pipefd[2]);
功能:创建无名管道
参数:pipefd 输出两个文件描述符:
  pipefd[0]  读取数据;
  pipefd[1]  写入数据。
返回值:成功返回0,失败返回-1

湘ICP备2025147565号-1
gongan beian 湘公网安备43102602000213号
CPU --% | 内存 0.00G/0.00G (0%) | 网络 无活动网卡
服务器资源占用 更新时间 --:--:--