[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH] getty: Wait until all output written to stdout has been
From: Denys Vlasenko <vda.linux () googlemail ! com>
Date: 2011-01-26 14:16:12
Message-ID: AANLkTikV2T5GOaP-cb0fByYVh_yi=j19yvzj=ZdV_zdt () mail ! gmail ! com
[Download RAW message or body]
On Mon, Jan 24, 2011 at 9:03 AM, Peter Korsgaard <jacmet@sunsite.dk> wrote:
> From 343e399118d1039cca8c55a5b865920e0b57f69d Mon Sep 17 00:00:00 2001
> From: Peter Korsgaard <jacmet@sunsite.dk>
> Date: Mon, 24 Jan 2011 09:02:01 +0100
> Subject: [PATCH] getty: wait up to 5 seconds for the output buffer to drain
>
> To not lose data on slow serial ports.
>
> Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
> ---
> loginutils/getty.c | 12 ++++++------
> 1 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/loginutils/getty.c b/loginutils/getty.c
> index bf66f22..c063f74 100644
> --- a/loginutils/getty.c
> +++ b/loginutils/getty.c
> @@ -232,12 +232,12 @@ static void open_tty(void)
> /* initialize termios settings */
> static void termios_init(int speed)
> {
> - /* Flush input and output queues, important for modems!
> - * Users report losing previously queued output chars, and I hesitate
> - * to use tcdrain here instead of tcflush - I imagine it can block.
> - * Using small sleep instead.
> - */
> - usleep(100*1000); /* 0.1 sec */
> + /* Wait up to 5 seconds for the output buffer to drain */
> + signal(SIGALRM, record_signo);
> + alarm(5);
> + tcdrain(STDIN_FILENO);
> + alarm(0);
> + signal(SIGALRM, SIG_DFL);
> tcflush(STDIN_FILENO, TCIOFLUSH);
>
> /* Set speed if it wasn't specified as "0" on command line. */
> --
> 1.7.2.3
Applied, thanks!
--
vda
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic