[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: dynamically generated files



On Mon, Apr 29, 2002 at 05:29:37PM +0930, Tom Cook wrote:
> On  0, Vineet Kumar <debian-user@virtual.doorstop.net> wrote:
> > * Scott Henson (shenson2@wvu.edu) [020428 20:03]:
> > > I need something that dynamically generates files on the file system. 
> > > Much like cgi.  I need it to just happen when a program accesses the
> > > file.  It will only be reading said file not executing it.  Anyone have
> > > any ideas on how to do this on a woody system with ext3 fs?  Thanks
> > 
> > Getting more specific would help. Probably what you want is a fifo, and
> > a process that continually writes to it. For example:
> > 
> > mkfifo /tmp/datefifo
> > 
> > while : 
> > do
> > echo `date` >> /tmp/datefifo
> > done
> > 
> > Then, see what happens when you cat /tmp/datefifo in another console.
> > (Try it a few times.)
> 
> I don't quite understand what this is doing.  What mechanism is used
> to implement the fifos?  And why does this happen?
> 
> # while true ; do echo `date` >> /tmp/datefifo ; done &
> # tail -f /tmp/datefifo
> Mon Apr 29 17:27:23 CST 2002
> Mon Apr 29 17:27:26 CST 2002
> Mon Apr 29 17:27:26 CST 2002
> Mon Apr 29 17:27:26 CST 2002
> Mon Apr 29 17:27:26 CST 2002
> 
> and that is all I get?  And why does the gnome-terminal with the while
> loop in it crash after a few more seconds?

Problem with FIFO's is they need a reader and a writer connected and
block until both are true.  I'm not sure why the terminal crashes, but
it ain't limited to gnome-terminal.  I expect it has something to do
with bash handling write/close errors on the FIFO which might generate
an unhandled signal (SIGPIPE, for instance).

BTW: FIFO's are handled in the kernel, and typically have a fixed buffer
size (say, 4096 bytes).

-- 
Eric G. Miller <egm2@jps.net>


-- 
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org



Reply to: