如何在打开/写入功能中实现超时

Kos*_*rio 6 c linux pipe fifo

我想使用命名的 fifo 通道,并且我想在写入这个 fifo 时实现超时。

fd = open(pipe, O_WRONLY);
write(fd, msg, len);
Run Code Online (Sandbox Code Playgroud)

程序被函数open 阻塞,所以使用函数select 将不起作用。谢谢。

Jea*_*nès 2

useselect()及其超时参数。

  • 如果是阻塞的“open”系统调用,它将不起作用(因为“select”和“poll”都需要打开的文件描述符) (2认同)