From: Harald Hoyer <[email protected]>
There might be a race condition that happens if you try to open
/dev/tty0 while the current TTY is currently being closed.
This would yield an -EIO error.
---
src/vconsole-setup.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/src/vconsole-setup.c b/src/vconsole-setup.c
index 1be260b..60a5f14 100644
--- a/src/vconsole-setup.c
+++ b/src/vconsole-setup.c
@@ -176,7 +176,21 @@ int main(int argc, char **argv) {
else
vc = "/dev/tty0";
+again:
if ((fd = open(vc, O_RDWR|O_CLOEXEC)) < 0) {
+ if (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;
+ }
log_error("Failed to open %s: %m", vc);
goto finish;
}
--
1.7.3.4
_______________________________________________
systemd-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/systemd-devel