fbsplash
Denys Vlasenko
vda.linux at googlemail.com
Fri Mar 28 11:56:30 UTC 2008
On Friday 28 March 2008 12:26, Michele Sanges wrote:
> > I don't know. You need to give more complete description of what you are doing.
> >
> > Here is my description:
> > <cut>
> > See? As soon as this block finished:
> >
> > {
> > echo 11
> > sleep 1
> > echo 22
> > sleep 1
> > } >/tmp/fbsplash.fifo
> >
> > and /tmp/fbsplash.fifo is closed on input side, reads
> > on output side do not block anymore, they return 0
> > immediately.
>
> I tried exactly your proceedings on your file and I got your same
> result.
> Then I tried the same procedure on the patch that I sent today and in
> this case, the read is blocking.
>
> Please, can you repeat the proceedings with my today patch, adding to it
> a short message after the read call?
Indeed, I see the same. The difference is...
fp = xopen(fifo_filename, O_RDWR);
You open fifo with O_RDWR, I open it with O_RDONLY.
Wow, I didn't know about this detail.
After some googling I found this info:
http://mail.python.org/pipermail/python-list/2006-August/396499.html
====================================================================
> I just found out that the general open file mechanism doesn't work
> for named pipes (fifo). Say I wrote something like this and it
> simply hangs python:
...just as it would "hang" any other language...!-). Looks like you may
not 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 I
selectively quote...:
"""
O_RDWR
Open for reading and writing. The result is undefined if this flag is
applied to a FIFO.
"""
(which means that your open with r+ _might_ cause the system to make
demons 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.
=================================================================
http://opengroup.org/onlinepubs/007908799/xsh/open.html
===============================================================
SYNOPSIS
int open(const char *path, int oflag, ... );
DESCRIPTION
...
O_RDONLY
Open for reading only.
O_WRONLY
Open for writing only.
O_RDWR
Open for reading and writing. The result is undefined if this flag is applied to a FIFO.
====================================================================
I learned something new today:
1. open(fifo, O_RDWR) on linux works, and changes read() behaviour.
2. unfortunately, it is not portable.
--
vda
More information about the busybox
mailing list