This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug] Named Pipes (FIFO) / Bash

I'm having problems with some bash scripts that were developed (not be
me) and working OK in Cygwin 1.6.x versions, but not in 1.7.x (tested on
1.7.6, 1.7.7 and the latest snapshot).  After some gnashing of teeth and
pulling of hair I've whittled it down to a problem with named pipe
handling in bash.  Sifting through the archives of the mailing lists
didn't provide much clues.  I realize from earlier discussions that
named pipes aren't fully supported, but some examples of programs and
scripts seem to indicate that they should at least work on a basic

I've tried both the current and the just announced experimental version
of bash and both Windows7/CoreDuo and WinXP/TurionX2 (I don't think the
dual cores have something to do with the problem, but if necessary I
should be able to at least boot the WinXP machine with only a single
core enabled).

$ mkfifo /tmp/pipe
$ ( sleep 10; echo -n "blafasel "; date; sleep 10; cat < /tmp/pipe )&
$ echo -n "dingdong "; date; exec 6> /tmp/pipe; echo -n "blumblum "; date
$ echo -n "hurrdurr " >&6; date

Running this on Linux outputs as expected:

dingdong Sa 22. Jan 20:41:45 CET 2011
blafasel Sa 22. Jan 20:41:55 CET 2011
blumblum Sa 22. Jan 20:42:05 CET 2011
hurrdurr Sa 22. Jan 20:42:05 CET 2011

On Cygwin, I get this:

dingdong Sa 22. Jan 20:41:45 CET 2011
blumblum Sa 22. Jan 20:41:45 CET 2011
blafasel Sa 22. Jan 20:41:55 CET 2011
cat: -: Communication error on send

In other words, opening the pipe is non-blocking, even though no
listener is present.  Listing /proc/self/fd lists fd 6 as opened to FIFO
/tmp/pipe, but any output to it blocks indefinitely.  I believe that the
FIFO has in fact never been opened as far as the system is concerned.
The output then blocks on the apparently not-open FIFO (I should be
getting a SIGPIPE instead when trying to write into a pipe that has no

Note: Looking at the problematic scripts I realize that the opening of
the FIFO must have been non-blocking in 1.6.x as well, but the output
was just blocked until the listener became available.

The last message goes away if I replace the "cat <" with simply "cat"
(this seems to be a separate bug in redirection handling of named pipes
which I could easily work around), but the shell still hangs up hard.  A
ps in another shell shows that bash is waiting for output and cat is
waiting for input.  I can then, however, write into the pipe from a
second shell and have the ouput appear in the tty of the first.

If I reverse the course of things and let the cat out first, so to
speak, then (and only then) everything works in a single shell.  This
however requires the very serialization that the named pipe was supposed
to provide.

I'd be grateful for any insights and/or ideas for possible workarounds.

+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Samples for the Waldorf Blofeld:

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]