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

Denys Vlasenko vda.linux at googlemail.com
Sat Jan 22 01:57:47 UTC 2011


On Thursday 20 January 2011 09:54, Michal Simek wrote:
> Problem was observed on a Xilinx Microblaze system with console on mdm
> IP (which is very slow), where part of the console output wasn't shown.
> 
> Calling tcdrain() instead of tcflush() fixes the problem.

But it may lead to a hang if serial line gets mangled:
in some situations tcdrain may wait forever.

I propose adding sleep(1) before the flush.
Can you verify that it works?

> @@ -266,8 +266,8 @@ static void termios_init(struct termios *tp, int speed)
>  	 * reads will be done in raw mode anyway. Errors will be dealt with
>  	 * later on.
>  	 */
> -	/* flush input and output queues, important for modems! */
> -	tcflush(0, TCIOFLUSH);
> +	/* wait until all output written to the stdout has been transmitted */
> +	tcdrain(STDOUT_FILENO);
>  	ispeed = ospeed = speed;
>  	if (speed == B0) {
>  		/* Speed was specified as "0" on command line.

-- 
vda


More information about the busybox mailing list