Commit cd453b38 by Daniel Lezcano Committed by Daniel Lezcano

fix default console to /dev/tty

Fix default console output fall into the current tty. Otherwise fall to /dev/null if no tty is available. Fix at the same time, Xorg take 100% cpu. Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent 81192358
......@@ -139,6 +139,29 @@ out_close:
return 1;
}
static get_default_console(char **console)
{
int fd;
if (!access("/dev/tty", F_OK)) {
fd = open("/dev/tty", O_RDWR);
if (fd > 0) {
close(fd);
*console = strdup("/dev/tty");
goto out;
}
}
if (!access("/dev/null", F_OK)) {
*console = strdup("/dev/null");
goto out;
}
ERROR("No suitable default console");
out:
return *console ? 0 : -1;
}
int lxc_create_console(struct lxc_conf *conf)
{
struct termios tios;
......@@ -148,8 +171,10 @@ int lxc_create_console(struct lxc_conf *conf)
if (!conf->rootfs.path)
return 0;
if (!console->path)
return 0;
if (!console->path && get_default_console(&console->path)) {
ERROR("failed to get default console");
return -1;
}
if (openpty(&console->master, &console->slave,
console->name, NULL, NULL)) {
......@@ -173,6 +198,8 @@ int lxc_create_console(struct lxc_conf *conf)
goto err;
}
DEBUG("using '%s' as console", console->path);
console->peer = fd;
if (!isatty(console->peer))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment