Opening FIFO file hangs in Linino

I've been working on something that uses a FIFO buffer to communicate between two processes (a cgi script served by uhttpd, and a python script that's communicating with the ATmega in place of the bridge) and am running into a problem where the open system call on the FIFO completely hangs (i.e. never returns).

Here's an easy way to repro with python--under the covers python is just calling the same system functions:

import os
# File /tmp/foo.fifo is successfully created
fd ='/tmp/foo.fifo', os.O_RDONLY)
# Execution hangs at the call above!
# Also attempting python's open call with open('/tmp/foo.fifo', 'r') also fails (to be expected since it's just calling the OS's open call

Also you will notice the '/tmp/foo.fifo' is successfully created, but if you try to write to it with a command like:

echo 'foo' > /tmp/foo.fifo

You will also get a lockup and the echo command never returns.

Anyone have any ideas why this might lock up? The same code works fine on my Ubuntu machine. Does OpenWRT not support FIFOs? I googled around and couldn't find any good info or bug reports unfortunately.

As a workaround I'll look at using unix sockets for intraprocess communication--the code is a little more complex, but hopefully it works on OpenWRT.

Actually the code fails on my Ubuntu machine in the same way--maybe I'm doing something wrong. Same code works fine on a Mac which seems odd. For now this might not really be a Linino issue.

Ahh found my problem, opening the FIFO for read will block until something else opens the FIFO for writing. If that’s not the desired behavior you can specify a flag in the call to open in non-blocking mode.

Odd that the behavior is different on a Mac, but oh well nothing to see here folks. :slight_smile: