[PATCH] getty: Wait until all output written to stdout has been transmitted
Peter Korsgaard
jacmet at sunsite.dk
Mon Jan 24 08:03:45 UTC 2011
>>>>> "Denys" == Denys Vlasenko <vda.linux at googlemail.com> writes:
Hi,
Denys> I committed a fix with usleep(100*1000) for now - it's better than what
Denys> we have now.
Denys> If you feel strongly about needing alarm-based fix, please send a patch
Denys> for review.
Ok, what about:
>From 343e399118d1039cca8c55a5b865920e0b57f69d Mon Sep 17 00:00:00 2001
From: Peter Korsgaard <jacmet at 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 at 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
--
Bye, Peter Korsgaard
More information about the busybox
mailing list