]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
agetty: use O_NONBLOCK only for serial lines with CLOCAL
authorKarel Zak <kzak@redhat.com>
Thu, 13 Jun 2013 09:06:13 +0000 (11:06 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 13 Jun 2013 09:30:02 +0000 (11:30 +0200)
 * 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 <kzak@redhat.com>
term-utils/agetty.c

index 76f56eb009d18c84cbd03ecf3ebdb5a6d693e43c..054a1dd6855ec7742009d08c7cd78f03f558e68e 100644 (file)
@@ -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) {