Skip to main content
added 799 characters in body
Source Link
Ljm Dullaart
  • 5.1k
  • 14
  • 27

Can named pipes be configured in a way so that these are durable?

Depending on your definition of durable, yes. mkfifo creates the fifo or named pipe, and it remains there until you delete it.

I read about "pinning" to pipe by the writer, but I fail to get that to work

Not sure what you mean by that. However, if you are not in control of the writer, this would not be a solution.

Can I prevent a pipe from getting closed once the reader exits?

You can use tail -f on the fifo, instead of a cat. Or even tail -n +1 -f fifo_name | command

Some additional information: whan cat encounters the end-of-file, it exits. So, if you do

$ mkfifo fifootje
$ cat fifootje

and in another terminal

echo hop > fifootje

you get the hop from the cat, and cat exits. If your writer then does

$ echo plop > fifootje

it hangs until a new cat fifootje is issued.

tail -f ("follow" or "forever") just waits until some lines are added and it does not exit until killed. So,

$ tail -f fifootje
hop
plop
and more text
entered via cat
^C

and in the writer terminal:

$ echo hop > fifootje 
ljm@verlaine[/tmp]$ echo plop > fifootje 
ljm@verlaine[/tmp]$ cat > fifootje
and more text
entered via cat
^D

Alternatively, you could:

while : ; do
    cat fifootje
done

Are there alternatives that behave like a pipe?

Yes, sockets.

Can named pipes be configured in a way so that these are durable?

Depending on your definition of durable, yes. mkfifo creates the fifo or named pipe, and it remains there until you delete it.

I read about "pinning" to pipe by the writer, but I fail to get that to work

Not sure what you mean by that. However, if you are not in control of the writer, this would not be a solution.

Can I prevent a pipe from getting closed once the reader exits?

You can use tail -f on the fifo, instead of a cat. Or even tail -n +1 -f fifo_name | command

Are there alternatives that behave like a pipe?

Yes, sockets.

Can named pipes be configured in a way so that these are durable?

Depending on your definition of durable, yes. mkfifo creates the fifo or named pipe, and it remains there until you delete it.

I read about "pinning" to pipe by the writer, but I fail to get that to work

Not sure what you mean by that. However, if you are not in control of the writer, this would not be a solution.

Can I prevent a pipe from getting closed once the reader exits?

You can use tail -f on the fifo, instead of a cat. Or even tail -n +1 -f fifo_name | command

Some additional information: whan cat encounters the end-of-file, it exits. So, if you do

$ mkfifo fifootje
$ cat fifootje

and in another terminal

echo hop > fifootje

you get the hop from the cat, and cat exits. If your writer then does

$ echo plop > fifootje

it hangs until a new cat fifootje is issued.

tail -f ("follow" or "forever") just waits until some lines are added and it does not exit until killed. So,

$ tail -f fifootje
hop
plop
and more text
entered via cat
^C

and in the writer terminal:

$ echo hop > fifootje 
ljm@verlaine[/tmp]$ echo plop > fifootje 
ljm@verlaine[/tmp]$ cat > fifootje
and more text
entered via cat
^D

Alternatively, you could:

while : ; do
    cat fifootje
done

Are there alternatives that behave like a pipe?

Yes, sockets.

Source Link
Ljm Dullaart
  • 5.1k
  • 14
  • 27

Can named pipes be configured in a way so that these are durable?

Depending on your definition of durable, yes. mkfifo creates the fifo or named pipe, and it remains there until you delete it.

I read about "pinning" to pipe by the writer, but I fail to get that to work

Not sure what you mean by that. However, if you are not in control of the writer, this would not be a solution.

Can I prevent a pipe from getting closed once the reader exits?

You can use tail -f on the fifo, instead of a cat. Or even tail -n +1 -f fifo_name | command

Are there alternatives that behave like a pipe?

Yes, sockets.