In my understanding, fd0 is for stdin, so a process would just read from it and never write. Similarly fd1 and fd2 are for stdout/stderr, so a process would just write to it. But it seems like bash/zsh open a tty device file just once in read-write (u) mode and duplicate it across the 3 descriptors. Questions regarding this:
- Is the understanding right?
- Is the duplication just to save multiple entries in system file table (each in different mode: r/w)? Would there be a difference in behavior?
- Is it safe to assume that bash/zsh would open fd0/1/2 in read-write (u) mode independent of operating system?