From 714cff30fd94d7fe6c7a8c6a1b4aa6cc8abd2ca7 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 13 Jun 2013 11:06:13 +0200 Subject: agetty: use O_NONBLOCK only for serial lines with CLOCAL * regression introduced by ef264c830effc91add6da334204215f61eb8515e * also increase sleep when O_NONBLOCK used (grr.. this is so stupid thing, do we really need O_NONBLOCK for the stupid serial lines?) References: https://bugzilla.redhat.com/show_bug.cgi?id=972457 Signed-off-by: Karel Zak --- term-utils/agetty.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'term-utils/agetty.c') diff --git a/term-utils/agetty.c b/term-utils/agetty.c index 76f56eb00..054a1dd68 100644 --- a/term-utils/agetty.c +++ b/term-utils/agetty.c @@ -321,9 +321,10 @@ int main(int argc, char **argv) strlen(options.initstring)); } - if ((options.flags & F_VCONSOLE) == 0 && - options.clocal == CLOCAL_MODE_ALWAYS) - /* Go to blocking write mode unless -L is specified. */ + if (options.flags & F_VCONSOLE || options.clocal != CLOCAL_MODE_ALWAYS) + /* Go to blocking mode unless -L is specified, this change + * affects stdout, stdin and stderr as all the file descriptors + * are created by dup(). */ fcntl(STDOUT_FILENO, F_SETFL, fcntl(STDOUT_FILENO, F_GETFL, 0) & ~O_NONBLOCK); @@ -1449,9 +1450,10 @@ static char *get_logname(struct options *op, struct termios *tp, struct chardata if (read(STDIN_FILENO, &c, 1) < 1) { - /* Do not report trivial like EINTR/EIO errors. */ + /* The terminal could be open with O_NONBLOCK when + * -L (force CLOCAL) is specified... */ if (errno == EINTR || errno == EAGAIN) { - usleep(1000); + usleep(250000); continue; } switch (errno) { -- cgit v1.2.3-55-g7522