diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-01-24 00:28:43 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-01-24 00:28:43 +0100 |
commit | dc6cd12569e6ac3775b11f6285ccc1bb81b13af0 (patch) | |
tree | 6582ae197a77d3622fdae4707df33c8bceab3226 | |
parent | 1f0840450e3934cc65520ee6605b9b72df2d53f5 (diff) | |
download | busybox-w32-dc6cd12569e6ac3775b11f6285ccc1bb81b13af0.tar.gz busybox-w32-dc6cd12569e6ac3775b11f6285ccc1bb81b13af0.tar.bz2 busybox-w32-dc6cd12569e6ac3775b11f6285ccc1bb81b13af0.zip |
getty: add sleep before initial tcdrain; reduce another sleep from 1 to 0.1s
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | loginutils/getty.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/loginutils/getty.c b/loginutils/getty.c index e60af3aa3..13b341db5 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c | |||
@@ -275,10 +275,13 @@ static void open_tty(const char *tty) | |||
275 | /* initialize termios settings */ | 275 | /* initialize termios settings */ |
276 | static void termios_init(struct termios *tp, int speed) | 276 | static void termios_init(struct termios *tp, int speed) |
277 | { | 277 | { |
278 | /* Flush input and output queues, important for modems! */ | 278 | /* Flush input and output queues, important for modems! |
279 | /* TODO: sleep(1)? Users report lost chars, and I hesitate | 279 | * Users report losing previously queued output chars, and I hesitate |
280 | * to use tcdrain here instead of tcflush */ | 280 | * to use tcdrain here instead of tcflush - I imagine it can block. |
281 | tcflush(0, TCIOFLUSH); | 281 | * Using small sleep instead. |
282 | */ | ||
283 | usleep(100*1000); /* 0.1 sec */ | ||
284 | tcflush(STDIN_FILENO, TCIOFLUSH); | ||
282 | 285 | ||
283 | /* Set speed if it wasn't specified as "0" on command line. */ | 286 | /* Set speed if it wasn't specified as "0" on command line. */ |
284 | if (speed != B0) | 287 | if (speed != B0) |
@@ -402,8 +405,8 @@ static char *get_logname(char *logname, unsigned size_logname, | |||
402 | /* NB: *cp is pre-initialized with init_chardata */ | 405 | /* NB: *cp is pre-initialized with init_chardata */ |
403 | 406 | ||
404 | /* Flush pending input (esp. after parsing or switching the baud rate). */ | 407 | /* Flush pending input (esp. after parsing or switching the baud rate). */ |
405 | sleep(1); | 408 | usleep(100*1000); /* 0.1 sec */ |
406 | tcflush(0, TCIOFLUSH); | 409 | tcflush(STDIN_FILENO, TCIOFLUSH); |
407 | 410 | ||
408 | /* Prompt for and read a login name. */ | 411 | /* Prompt for and read a login name. */ |
409 | logname[0] = '\0'; | 412 | logname[0] = '\0'; |
@@ -659,7 +662,7 @@ int getty_main(int argc UNUSED_PARAM, char **argv) | |||
659 | * by patching the SunOS kernel variable "zsadtrlow" to a larger value; | 662 | * by patching the SunOS kernel variable "zsadtrlow" to a larger value; |
660 | * 5 seconds seems to be a good value. | 663 | * 5 seconds seems to be a good value. |
661 | */ | 664 | */ |
662 | if (tcgetattr(0, &termios) < 0) | 665 | if (tcgetattr(STDIN_FILENO, &termios) < 0) |
663 | bb_perror_msg_and_die("tcgetattr"); | 666 | bb_perror_msg_and_die("tcgetattr"); |
664 | 667 | ||
665 | pid = getpid(); | 668 | pid = getpid(); |
@@ -667,9 +670,9 @@ int getty_main(int argc UNUSED_PARAM, char **argv) | |||
667 | // FIXME: do we need this? Otherwise "-" case seems to be broken... | 670 | // FIXME: do we need this? Otherwise "-" case seems to be broken... |
668 | // /* Forcibly make fd 0 our controlling tty, even if another session | 671 | // /* Forcibly make fd 0 our controlling tty, even if another session |
669 | // * has it as a ctty. (Another session loses ctty). */ | 672 | // * has it as a ctty. (Another session loses ctty). */ |
670 | // ioctl(0, TIOCSCTTY, (void*)1); | 673 | // ioctl(STDIN_FILENO, TIOCSCTTY, (void*)1); |
671 | /* Make ourself a foreground process group within our session */ | 674 | /* Make ourself a foreground process group within our session */ |
672 | tcsetpgrp(0, pid); | 675 | tcsetpgrp(STDIN_FILENO, pid); |
673 | #endif | 676 | #endif |
674 | 677 | ||
675 | /* Update the utmp file. This tty is ours now! */ | 678 | /* Update the utmp file. This tty is ours now! */ |