4

I am trying to use named pipes as a convenient way to preprocess input on the fly for pipelines that sadly do not accept data from stdin directly.

everywhere I look for info I get basically the same gist: Named pipes should be dead simple to use.

the gist is mostly that the following should work:

mkfifo mynamedpipe echo "is this working?" > mynamedpipe cat mynamedpipe

when i run mkfifo mynamedpipe, the pipe is successfully created and visible with ls *.

But even after i grant myself write permission to that pipe, when i try to run echo "whatever" > mynamedpipe nothing happens and the terminal just hangs until I kill the process with ctrl+c.

I have this problem on my local linux machine (Ubuntu 14.04.5 LTS) as well as on a public server (Red Hat Enterprise Linux 7), and in zsh as well as in bash.

What am I doing wrong here?

jov14
  • 65

1 Answers1

2

This post seems to relate to your problem : Cat to named pipe causes hang.

The relevant remarks are :

  • You need to have something reading from the FIFO
  • Ensure that the pipe is created with a large enough buffer or readers are fast enough to avoid blocking
  • You need to assign the pipe to a file descriptor, as in :

    exec 3<>/tmp/stream_pipe
    
harrymc
  • 498,455