Only do tty validation when using a NCursesUI
This commit is contained in:
parent
1b08b79989
commit
48007d5de2
23
src/main.cc
23
src/main.cc
|
@ -243,17 +243,20 @@ void create_local_client(StringView init_command)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (not isatty(1))
|
if (std::is_same<UI, NCursesUI>::value)
|
||||||
throw runtime_error("stdout is not a tty");
|
|
||||||
|
|
||||||
if (not isatty(0))
|
|
||||||
{
|
{
|
||||||
// move stdin to another fd, and restore tty as stdin
|
if (not isatty(1))
|
||||||
int fd = dup(0);
|
throw runtime_error("stdout is not a tty");
|
||||||
int tty = open("/dev/tty", O_RDONLY);
|
|
||||||
dup2(tty, 0);
|
if (not isatty(0))
|
||||||
close(tty);
|
{
|
||||||
create_fifo_buffer("*stdin*", fd);
|
// move stdin to another fd, and restore tty as stdin
|
||||||
|
int fd = dup(0);
|
||||||
|
int tty = open("/dev/tty", O_RDONLY);
|
||||||
|
dup2(tty, 0);
|
||||||
|
close(tty);
|
||||||
|
create_fifo_buffer("*stdin*", fd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Client* client = ClientManager::instance().create_client(
|
static Client* client = ClientManager::instance().create_client(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user