From: Jeff Dike <jdike@ka...> - 2001-02-21 18:27:13
> if(isatty(0)) tcsetattr(0, TCSADRAIN, &tt);
> else if(isatty(1)) tcsetattr(1, TCSADRAIN, &tt);
> else tcsetattr(2, TCSADRAIN, &tt);
> ... As I understand what the code is doing here is saving the state
> of standard fd's, but don't all 3 of them usually refer to a tty?
Heh. Keep poking around and you'll continue to find little gems like that.
That code is basically assuming that the terminals that it's attached to are
cooked to start with. So, it grabs the flags from one of them, and restores
those flags to all of them when it exits.
Your suggestion would be an improvement.