我用这个创建了一个 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/