Unix系统编程:文件打开错误

时间:2011-04-29 16:34:05

标签: unix file-io

我正在尝试打开一个我在open命令之前创建的文件。但它挂起在open()命令行。你有什么想法吗?

if(mkfifo("test", S_IRWXU | S_IRWXG | S_IRWXO))
{
    printf("File creation error.\n");
    return 0;
}

// Hangs below
while (((test_fd = open("test", O_RDONLY)) == -1) && (errno == EINTR));

1 个答案:

答案 0 :(得分:2)

来自mkfifo的联机帮助页:

 Opening a FIFO for reading normally blocks until some other process opens  the  same  FIFO for  writing,  and vice versa.
 See fifo(7) for nonblocking handling of FIFO special files.