2

Does mkfifo simply not work with Cygwin? A simple set of commands such as

$ mkfifo my_pipe

$ echo "1234" > my_pipe

just causes the terminal to sit forever with the cursor blinking. Am I "doing it wrong"?

Zombo
  • 1
  • 62
  • 391
  • 407

2 Answers2

4

No, you're not doing anything wrong with either of those commands, it's just your expectations are a little off.

What you're missing is something at the other end of that pipe, reading that data. This apparent hanging happens in Linux as well, so it's not a CygWin problem (or any sort of problem, really).

Just open up another window and enter:

cat <my_pipe

and you'll see the data appear, followed by the original echo completing.

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
  • But what happens that one gets a blinking cursor here? Is it that the command is just not (yet) executed as one presses ? If one adds `&` at the end of the `echo` command, the process is sent running in the background, waiting for the other end of the pipe to be read from, so this means that the command *is* executed. So is it then that the command does get executed but the resulting process stands in a special mode/status, and if so what is this status? – The Quark Oct 30 '21 at 12:37
  • @TheQuark: it's more accurate to say that, once you hit ENTER, the command is *executing* rather than executed. There are three states here, not two: before running, running, and finished. The same thing happens with the command `sleep 60` - while the program is running, all you will see is that blinking cursor. The bottom line is that `echo` has not yet completed its task so will not exit. – paxdiablo Oct 30 '21 at 22:15
0

The thing with named pipes is that you need to have something on both ends. You can't write into a pipe if it isn't complete yet, so the echo command hangs until something else tries to read from that pipe, which in your case never happens.

Dan
  • 10,531
  • 2
  • 36
  • 55