这最后一段是至关重要的: 的基本语义Unix中的FIFO用于写入和读取过程(或更现代的 线程 ; :-) torendezvous围绕他们各自的打开(2), 阻塞,直到他们都达到开放点。 非阻塞情况下的语义有些奇怪(以我的思维方式,但是,然后,我的Unix背景_有点过时了!)但是他们无论如何我都不会帮助你 - 看起来你会喜欢完全不同的 语义(既没有打开阻止,也没有阅读一个),但是 Unix并没有真正提供给他们...... Alex....just as it would "hang" any other language...!-). Looks like you maynot be fully cognizant of the semantics of fifos -- understandably,because the man pages on most systems are not too limpid on the subject.But there''s a good one, e.g., at<http://opengroup.org/onlinepubs/007908799/xsh/open.html, and Iselectively quote...:"""O_RDWROpen for reading and writing. The result is undefined if this flag isapplied to a FIFO."""(which means that your open with r+ _might_ cause the system to makedemons fly out of your nose, according to e.g.<http://everything2.com/index.pl?node_id=922462...:-); so, _don''t_ use''r+'' to open your fifo. But, moreover...:"""O_NONBLOCKWhen opening a FIFO with O_RDONLY or O_WRONLY set: If O_NONBLOCK is set:An open() for reading only will return without delay. An open() forwriting only will return an error if no process currently has the fileopen for reading.If O_NONBLOCK is clear:An open() for reading only will block the calling thread until a threadopens the file for writing. An open() for writing only will block thecalling thread until a thread opens the file for reading."""This last paragraph is the crucial one: the fundamental semantics ofFIFOs in Unix is for the writing and reading processes (or more modernly"threads":-) to "rendezvous" around their respective calls to open (2),blocking until both of them reach the open point. The semantics in thenonblocking case(s) are somewhat weird (to my way of thinking, but then,my Unix background _is_ somewhat dated!-), but they wouldn''t help youanyway, it seems to me -- looks like you''d like drastically differentsemantics (with neither open blocking, or just the reading one), butUnix just doesn''t really offer them...Alex 这篇关于Python打开一个命名管道==挂?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-15 01:44