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

Rob Landley rob at landley.net
Mon Jan 24 02:05:44 UTC 2011


On 01/23/2011 02:44 PM, Denys Vlasenko wrote:
> On Sunday 23 January 2011 20:44, Peter Korsgaard wrote:
>>>>>>> "Rich" == Rich Felker <dalias at aerifal.cx> writes:
>>
>> Hi,
>>
>>  Rich> Is there a reason you're not considering the alarm approach?
>>  Rich> alarm+drain will not hang at all if the buffer drains immediately.
>>  Rich> sleep+flush or usleep+flush will *always* sleep at least some
>>  Rich> interval, which is annoying to the user.
>>
>> Indeed. It seems vastly superior, and only slightly more complicated.
> 
> What happened to "we are busybox, we like simple solutions"?
> Rob periodically grills me that I am making it too complicated...

Bwahahahaha!

(Reads thread...)

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?

More to the point, do modems actually get used anywhere anymore?
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()?  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...)

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'm going to stop before I have to start rewriting the thing myself...

Rob



More information about the busybox mailing list