>>>>> "Denys" == Denys Vlasenko <[email protected]> writes:
>>>> DV> I propose adding sleep(1) before the flush. Can you verify that it
>>>> DV> works?
>>>>
>>>> alarm+tcdrain maybe? This way it won't wait a second if there is nothing
>>>> to drain.
>>>
>>> Indeed this is a much better solution. Calling sleep(1) is really
>>> annoying.
>>
>> Give me what I should test and I will do it.
Denys> Insert sleep(1) before tcflush(0, TCIOFLUSH) in termios_init in getty.c,
Denys> and let us know whether the "getty nukes a few last output chars sent
Denys> before it is started" problem has been fixed by it.
Denys> If it does, experiment with smaller sleeps - use usleep(MICROSECONDS) -
Denys> and let us know what minimal pause is enough. Also let us know
Denys> the settings on the serial line (primarily baud rate). If you can use
Denys> different ones, experiment with smallest available.
The needed delay (obviously) depends on baudrate and amount of data in
the buffer, so it's impossible to come up with a delay that would fit
everyone while still not delaying more than needed.
Why not use the alarm() approach like suggested? E.G. something like
(untested):
diff --git a/loginutils/getty.c b/loginutils/getty.c
index 015f077..d817d5d 100644
--- a/loginutils/getty.c
+++ b/loginutils/getty.c
@@ -276,9 +276,11 @@ static void open_tty(const char *tty)
/* termios_init - initialize termios settings */
static void termios_init(struct termios *tp, int speed)
{
- /* Flush input and output queues, important for modems! */
- /* TODO: sleep(1)? Users report lost chars, and I hesitate
- * to use tcdrain here instead of tcflush */
+ /* Wait up to 5 seconds for the output buffer to drain */
+ signal(SIGALRM, record_signo);
+ alarm(5);
+ tcdrain(0);
+ alarm(0);
tcflush(0, TCIOFLUSH);
/* Set speed if it wasn't specified as "0" on command line. */
This adds around 40 bytes.
--
Bye, Peter Korsgaard
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox