On 07/20/10 11:01, Eric Blake wrote: > In looking at it further, I'm lost as to where the SIGPIPE is coming > from; maybe we're facing a bash bug? Your point, that we should have > read back all the tokens already, seems valid, particularly since fifo > writes and reads should be atomic.
System call writes and reads should be atomic, but there's no requirement that the shell must implement "echo token" as an atomic write of 6 bytes. If the shell sometimes implements "echo token" as multiple writes, that alone would explain the problem. I suggest replacing "echo token" with "echo ''", so that a token is always a single newline byte. This may have nothing to do with your problem, but it should be done anyway, to make the script more portable. And if bash or the kernel does have bugs with respect to atomicity, it will make the script less liable to run into the bugs.
