[PATCH] getty: Wait until all output written to stdout has been transmitted

Denys Vlasenko vda.linux at googlemail.com
Mon Jan 24 03:44:56 UTC 2011

On Monday 24 January 2011 03:05, Rob Landley wrote:
> Wow, what a horrible leftover from the 1970's.  You realize that actual
> teletype hardware hasn't been connected to Linux machines in... um,
> forever?  The login command prompts for login: what exactly is getty
> supposed to be doing here?

From the code, getty is supposed to set termios parameters.
login doesn't do that, it expects those param to be set.

Actually, other getties (mgetty IIRC) are much more advanced
in this regard: they can set not only baud rate, but also
7/8 bits, and various kinds of parity, do expect/send handshake,
and even receive faxes (!) :)

> More to the point, do modems actually get used anywhere anymore?

Modems probably no, serial lines yes.

> Specifically, if somebody has a program listening to a modem line that's
> going to be doing a +++ATH thing and answering a phone, can't it be
> _that_ program's problem to flush the serial buffer if they really need
> to?  Do we need to do this flush at all?

> Could somebody at least tell me WHY this is important for modems?  What
> do the modems do if we don't call tcflush()?

From getty's POV, the tty may be in a "bad" state: serial line with
RTS/CTS lines set to "don't send". Getty wants to avoid being

> The program in question is
> copyright 1989, and one of the first comments is about heuristics to
> distinguish System V from SunOS 4.  Maybe, just MAYBE, some of what it's
> doing is no longer relevant to modern hardware, even the embedded stuff.

> (Wandering through and seeing comments like "I doubt there are systems
> which still need this", "Optionally detect the baud rate from the modem
> status message"...  We have #undef HANDLE_ALLCAPS and then large #ifdef
> chunks for HANDLE_ALLCAPS...)

I need to be bolder and just nuke that crap instead of #ifdef'ing it out.

> Ok this chunk of the file needs to die:
> /* Optionally wait for CR or LF before writing /etc/issue */
> if (option_mask32 & F_WAITCRLF) {
>         char ch;
>         debug("waiting for cr-lf\n");
>         while (safe_read(STDIN_FILENO, &ch, 1) == 1) {
>                 debug("read %x\n", (unsigned char)ch);
>                 ch &= 0x7f;                     /* strip "parity bit" */
>                 if (ch == '\n' || ch == '\r')
>                         break;
>         }
> }
> Strip parity bit?  Really?

I am deleting "ch &= 0x7f", but otherwise this fragment doesn't look wrong.

> I'm going to stop before I have to start rewriting the thing myself...

Please pull and take a look at the simplified version I just committed.


More information about the busybox mailing list