Reputation: 2805
Given two programs A and B.
A produces output.
B consumes input.
On Linux you can connect them with A | B
.
Alternatively, if I want to split the execution of those programs, i can use a named pipe:
mkfifo pipe
A > pipe &
B < pipe &
However if I terminate B, A gets also killed.
Is there a way to connect A to B, while restarting B multiple times? It is not important that B loses data (e.g. during being killed in the following example), while not running. Following would be my goal, but it does not work:
mkfifo pipe
A > pipe &
B > pipe &
kill B
B > pipe &
Why do I need this?
In my case A is the JSON output from Wireshark and i am developing B to parse the correct data.
I would like to do it interactively but for that i need Wireshark (or tshark
) to continue sending data.
I am aware of possible duplicates with this and that, however my question is different. I did not forget to redirect A to somewhere else, I can prepare it beforehand.
Upvotes: 2
Views: 253
Reputation: 50750
A
receives a SIGPIPE
the moment B
terminates. A workaround is:
exec 3<>pipe
A >&3 &
B <&3 &
This way the kernel won't signal A
when B
dies as the fifo was opened for reading by another process; i.e B
wasn't the last process reading from it.
Upvotes: 2