This is literally how bash, zsh, and dash implement `cmd1 | cmd2 | cmd3` internally, using `pipe()`, `fork()`, and `dup2()` in exactly the sequence you'll write here. Forgetting to close the pipe's write end in every process that isn't writing to it is a real, well-documented bug class that causes pipelines to hang forever because the reading command never receives EOF, which is why shell source code is meticulous about closing every unused descriptor after each fork.