c - 使用open时什么会导致无限循环? (C, UNIX)

标签 c unix infinite-loop mkfifo

我用这个创建了一个 fifo:mkfifo("myfifo", 0666);
现在,我想使用 inf fd = open("./myfifo",O_WRONLY); 打开它,但这会让我陷入无限循环,为什么?

最佳答案

来自 fifo(7) 手册页:

The FIFO must be opened on both ends (reading and writing) before data can be passed. Normally, opening the FIFO blocks until the other end is opened also.

你所拥有的不是无限循环。您的进程只是被阻塞,等待打开管道的另一端。

关于c - 使用open时什么会导致无限循环? (C, UNIX),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23978553/

相关文章:

c - Autoconf 检查 struct flock

linux - shell 导出变量没有生效

bash - 在期望脚本中发送 INSERT 和 F12

unix - 将 shell 的结果作为 Int 存储在变量中

python - while 循环和 python

c - 程序在 printPoly() 函数中进入无限循环

c++ - 在 C 中制作一个基本的 shell 并且在管道/ fork 方面遇到麻烦

c - 信号错误: "invalid use of void expression"

java - 等待函数有逻辑错误

在 Ubuntu 上的 MonoDevelop 中编译并运行 C 代码