我在Linux上发现了许多关于管道的问题和答案,但几乎所有人都在讨论读者方面。
对于一旦准备好将数据传递到命名管道的进程,只要数据可用和就连接了一个读取过程,有没有办法在非-blocking 时尚:
我理解如何做(2.),但我无法找到(1.)和(3。)的一致答案。
编辑:我正在为管道寻找(类似的)FIONWRITE,但Linux没有FIONWRITE(用于管道)(?)EDIT2:编写器的预期主循环(伪代码的种类,目标语言是C / C ++):
forever
poll(can_read_command, can_write_to_the_fifo)
if (can_read_command) {
read and parse command
update internal status
continue
}
if (can_write_to_the_fifo) {
length = min(data_available, space_for_nonblocking_write)
write(output_fifo, buffer, length)
update internal status
continue
}