在C中打开FIFO时遇到问题 [英] Having a trouble with opening FIFO in C

查看:135
本文介绍了在C中打开FIFO时遇到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C中打开FIFO时遇到了麻烦。首先我用mkfifo()函数创建了它们,权限为0777,当我试图打开它们时,它成功地打开了第一个FIFO,然后进程将停留在打开第二个FIFO,这是我的代码:

$ $ $ $ $ c $ fd1 = open(FIFO1_PATH,O_WRONLY);
fd2 = open(FIFO2_PATH,O_WRONLY);

这不会被执行,但是一旦我注释了第二行,它就会执行!每个流程的开放FIFO数量是否有限制?我不知道为什么会发生这种情况..我只花了3小时试图找出问题是什么,但没有任何结果:($ / b $ b

解决方案为了回答你关于限制的问题 - 在Linux中,默认情况下是一个进程的1024个文件描述符,你的问题可能不是打开第二个FIFO来读取写入数据块。

I'm having a trouble in opening FIFOs in C.. first I created them using mkfifo() function with permission : 0777, and when I tried to open them, it succeeded in opening the first FIFO only, then the process will stuck in opening the second FIFO, and this is my code :

fd1 = open("FIFO1_PATH", O_WRONLY );
fd2 = open("FIFO2_PATH", O_WRONLY );

This will not be executed, but once I comment the second line, it executes ! Is there a limit for the number of opening FIFOs per process ? I don't know why is this happening.. I just spent 3 Hours trying to figure out what the problem is, but without any results :(

解决方案

To answer you question about limits - default in Linux is 1024 file descriptors for a process. Your problem is probably not opening the second FIFO for reading so open for writing blocks.

这篇关于在C中打开FIFO时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆