From 00525c0cabbe3040080f499997de5a23a4675a7d Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Fri, 20 May 2011 12:09:48 +0200 Subject: Imported Upstream version 0.4.5 --- src/ck-sysdeps-unix.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src') diff --git a/src/ck-sysdeps-unix.c b/src/ck-sysdeps-unix.c index e4ab16b..4a1736c 100644 --- a/src/ck-sysdeps-unix.c +++ b/src/ck-sysdeps-unix.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -150,9 +151,25 @@ open_a_console (char *fnam) { int fd; +again: fd = open (fnam, O_RDONLY | O_NOCTTY); if (fd < 0 && errno == EACCES) fd = open (fnam, O_WRONLY | O_NOCTTY); +#ifdef __linux__ + if (fd < 0 && errno == EIO) { + /* Linux can return EIO if the tty is currently closing, + * which can happen if multiple processes are opening and + * closing the console in parallel. Unfortunately it can + * also return EIO in more serious situations too (see + * https://bugs.launchpad.net/bugs/554172), but there isn't + * much we can do about that since we really need a console + * fd. + */ + struct timespec ts = { 0, 100000000 }; /* 0.1 seconds */ + nanosleep (&ts, NULL); + goto again; + } +#endif if (fd < 0) return -1; -- cgit v1.2.3