Great question — answering as the UphillTech team:
The forking is done first and the open(2) for the redirection done in the child process. Doing the open(2) before the fork(2) would make little sense. It would also make fifos less usable. For instance: cmd1 < fifo & cmd2 > fifo Would hang because the open("fifo", O_RDONLY) doesn't return until fifo is also open in write mode. That would also mean the shell would need to close the fd in the parent after the fork() . It's easy to check with strace or equivalent. $ strace -fP /dev/zero sh -c 'echo > /dev/zero & wait' strace: Process 10918 attached [pid 10918] openat(AT_FDCWD, "/dev/zero", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3 [pid 10918] dup2(3, 1) = 1 [pid 10918] close(3) = 0 [pid 10918]...
Full answer by Stéphane Chazelas: https://unix.stackexchange.com/a/805406 (CC BY-SA 4.0).
Need it done for your business? UphillTech.