Cygwin1.dll 1.5.19: race condition & deadlock with fifos
Barry Kelly
barry.j.kelly@gmail.com
Mon Jun 12 01:23:00 GMT 2006
I'm having a problem trying to script with fifos under the bash shell.
There appears to be a race condition which results in a deadlock when
fifos are being read and written in quick succession (but just a single
read and write, so there are no interleaving issues).
This code with an explicit delay before the write, running under bash
3.1.17(6)-release (on Cygwin1.dll 1.5.19), works as expected:
---8<---
~/test-fifo$ mkfifo fifo
~/test-fifo$ ((sleep 1; echo foo >fifo)&); echo Read: $(<fifo)
Read: foo
--->8---
This code, with a delay before the read, also works:
---8<---
~/test-fifo$ rm fifo
~/test-fifo$ mkfifo fifo
~/test-fifo$ ((echo foo >fifo)&); sleep 1; echo Read: $(<fifo)
Read: foo
--->8---
This code, without a delay, causes a deadlock and both active spawned
bash processes (the forked one reading from the fifo and the
backgrounded one) need to be killed explicitly:
---8<---
~/test-fifo$ rm fifo
~/test-fifo$ mkfifo fifo
~/test-fifo$ ((echo foo >fifo)&); echo Read: $(<fifo)
--->8---
I am not subscribed: please CC me if you reply.
-- Barry
--
http://barrkel.blogspot.com/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygcheck.out
Type: application/octet-stream
Size: 57258 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20060612/d4af63e6/attachment.obj>
-------------- next part --------------
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
More information about the Cygwin
mailing list