问题描述
大家好奇怪,当我使用open()打开FIFO写入时,我发现当我使用
open(Fifo,O_WRONLY | O_CREAT | O_TRUNC);
它会阻止
i真的很困惑
write()不是由C标准定义的。你需要发布一个
appriate新闻组。也许是讨论Unix的人。
-
Nick Keighley
这是你应该带到另一个新闻组的问题(我想这可能是因为
comp.unix.programmer可能会这样做)因为open()函数和
FIFO都不是由C语言定义的(这个组的主题为
),但是是扩展名,例如由POSIX标准定义,
因此,处理POSIX的小组是你应该问的小组。
< OffTopic>
首先,O_TRUNC在打开FIFO和O_CREAT时也没用,因为你需要使用mkfifo()创建它。第二,打开一个FIFO的
总是阻塞,直到双方都打开它(除非
你以非阻塞模式打开它),请参见fifo(4)的手册页并且
mkfifo(3),两者都指出了这一点。
< / OffTopic>
问候,Jens
-
\ Jens Thoms Toerring ___
\ __________________________
不要在Usenet中使用html或mime类型。
-
Chuck F(cinefalconer at maineline dot net)
可用于咨询/临时嵌入式和系统。
< http://cbfalconer.home.att。网>
hi all, it strange, when i use open() to open a FIFO to write, but i find when i use
open(Fifo,O_WRONLY | O_CREAT | O_TRUNC);
it will block
i really confused
write() is not defined by the C standard. You need to post on an
appriate news group. Perhaps one that discusses Unix.
--
Nick Keighley
That''s a question you should take to another newsgroup (I guess that
comp.unix.programmer might do) since neither the open() function nor
FIFOs are something that are defined by the C language (the topic of
this group) but are extensions e.g. defined by the POSIX standard,
thus a group dealing with POSIX is the one where you should ask.
<OffTopic>
First, O_TRUNC is useless when opening a FIFO and O_CREAT also, be-
cause you already need to have created it using mkfifo(). Second,
opening a FIFO always blocks until both sides have opened it (unless
you open it in non-blocking mode), see the man page for fifo(4) and
mkfifo(3), both pointing this out.
</OffTopic>
Regards, Jens
--
\ Jens Thoms Toerring ___ [email protected]
\__________________________ http://toerring.de
Don''t use html or mime types in Usenet.
--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
这篇关于阻止打开()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!