On Sat, Aug 16, 2003 at 06:24:09AM -0700, moseley@hank.org wrote: > I wanted to use a named pipe to provide random images. I know I can use > a program in a loop writing to the pipe, but that means starting the > program initially (from say a init.d or xdm startup script) where it > sits blocked until read from. > > Question: > > Is there a way in Linux to have the action of the reading program > opening the pipe (for reading) start up the writing program? > > For example, if output_image.pl is a script that writes an image to a > named pipe, is there a way to associate it to a pipe where you can say: > > $ display some_named_pipe > > and have that action execute the program output_image.pl? > > I'm just wondering if there's a way to avoid starting the writing > program. I think you could do something of the kind by making output_image.pl provide its output over a network port, and configure inetd to wake up output_image.pl when it receives a connection to that port. (I've never tried anything like this, but I know that exim, for example, can be configured to behave like this.) Alternatively, you could have your program-in-a-loop method consume minimal resources by having a tiny little binary that does nothing but sit and wait for something to read from the pipe, then when something does, forks another process to actually provide the data. -- Pigeon Be kind to pigeons Get my GPG key here: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x21C61F7F
Attachment:
pgpIUBB5dlpT8.pgp
Description: PGP signature