[TUHS] FD 2

arnold at skeeve.com arnold at skeeve.com
Tue Jan 31 00:30:31 AEST 2023


John Cowan <cowan at ccil.org> wrote:

> On Mon, Jan 30, 2023 at 2:50 AM <arnold at skeeve.com> wrote:
>
> > What I really like is how in V8 - V10 /dev/tty was a (sym)link to /dev/fd/3,
> > and init simply did one more dup call. That eliminated the special tty
> > device
> > driver and was a lovely generalization / simplification.  It's too bad this
> > was never picked in the commercial Unixes or in Linux.
>
> That's problematic.  I often need to redirect 2>&1 in order to get a stream
> of both output and error into a file or into less(1), without interfering
> with *input* from the terminal, as for example a password.

I don't see how. Input is from fd 0. fd 3 is open on the original terminal
device by init, so even if you closed fd 0, opening /dev/tty gets you fd 3
gets you the original tty.

Granted, someone could also redirect fd 3, but that's unlikely in most cases.

Arnold


More information about the TUHS mailing list