diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2015-03-24 19:38:03 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2015-03-24 19:38:03 +0000 |
| commit | 48007d5de22f57175115fc72fe9cb592e6b0efb2 (patch) | |
| tree | 357e6a1c8dfd23fc7a415adf3fe491d92b7162db /src | |
| parent | 1b08b799899e456551c2f94ab1ad1ca0f95b2731 (diff) | |
Only do tty validation when using a NCursesUI
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.cc | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/main.cc b/src/main.cc index c76ca981..9c6829d6 100644 --- a/src/main.cc +++ b/src/main.cc @@ -243,17 +243,20 @@ void create_local_client(StringView init_command) } }; - if (not isatty(1)) - throw runtime_error("stdout is not a tty"); - - if (not isatty(0)) + if (std::is_same<UI, NCursesUI>::value) { - // 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); + if (not isatty(1)) + throw runtime_error("stdout is not a tty"); + + if (not isatty(0)) + { + // 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( |
