It's impossible to make reading from a pipe launch a process on a normal filesystem. But there are other methods that should do what you need.
You can run the content-generating program in a loop. Each time the FIFO is opened for writing, this will block until a reader comes along.
while true; do
generate-content >fifo
done
Another approach is to make a FUSE filesystem that generates whatever content you like — the data returned to the reader is generated by the filesystem driver, which is an ordinary program, so you can make it do whatever you like. Building a FUSE filesystem driver is a lot of work though, so unless you find one that already does exactly what you need this is probably overkill. Some possible filesystems that may help you are:
- ScriptFS — judging by the description, this does exactly what you need: “replicates a local file system, but replaces all files detected as ‘scripts’ by the result of their execution”. I've never used it.
- HTTPFS — reading from the file triggers a web download; connect it to localhost and run a small webserver such as lighttpd or thttpd that supports CGI or a similar method to serve dynamic content. If the data you need is already downloaded from a webserver, simply point HTTPFS at it.
while true; do (echo -n ""; curl ... > tmp; cat tmp) > /path/to/fifo; done
. – Mark Plotnick Jan 21 '15 at 23:48