public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Problem with named pipes
@ 2015-12-25 21:39 Ken Brown
  2016-01-08 20:58 ` Corinna Vinschen
  0 siblings, 1 reply; 5+ messages in thread
From: Ken Brown @ 2015-12-25 21:39 UTC (permalink / raw)
  To: cygwin

I've noticed a difference between Cygwin and Linux involving named 
pipes.  I don't know if this a bug or simply a difference.

Consider the following two scripts:

$ cat fifo1.sh
#!/bin/sh
set -x
rm -f foo
mkfifo foo
exec 7>foo
echo blah > foo

$ cat fifo2.sh
#!/bin/sh
set -x
read bar < foo
echo $bar

I run fifo1.sh in Terminal 1 and get the following on both Cygwin and Linux:

[Terminal 1]
$ ./fifo1.sh
+ rm -f foo
+ mkfifo foo
+ exec

The call to echo in the next line blocks, because foo has not yet been 
opened for reading.  Now I run fifo2.sh in Terminal 2.  On Linux, the 
"read" in fifo2.sh unblocks fifo1.sh, and I see the following:

[Terminal 1, Linux]
$ ./fifo1.sh
+ rm -f foo
+ mkfifo foo
+ exec
+ echo blah

[Terminal 2, Linux]
$ ./fifo2.sh
+ read bar
+ echo blah
blah

On Cygwin, however, Terminal 1 remains blocked, and Terminal 2 is 
blocked when it tries to read:

[Terminal 2, Cygwin]
$ ./fifo2.sh
+ read bar

The problem disappears if I remove the line "exec 7>foo" from fifo1.sh. 
  The problem also disappears if I leave that line in, but change the 
last line to "echo blah >&7".

Ken

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-12-11 19:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-25 21:39 Problem with named pipes Ken Brown
2016-01-08 20:58 ` Corinna Vinschen
2018-12-11 14:42   ` Ken Brown
2018-12-11 14:57     ` Dan Kegel
2018-12-11 19:40     ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).