diff options
| author | Enrico Zandomeni Borba <enricozb@gmail.com> | 2024-12-23 09:21:08 +0100 |
|---|---|---|
| committer | Enrico Zandomeni Borba <enricozb@gmail.com> | 2024-12-23 09:21:08 +0100 |
| commit | 14cb35f62b36b2f1aa530adb5e31c05ff1347bfc (patch) | |
| tree | 947d55e7cbdc29761d4e3f1e2cf516fa1f5cc6b4 /src/main.cc | |
| parent | 10ed78fe8a580b3558348746ee53f81c5b0aeae1 (diff) | |
create *stdin* buffer even when daemon
Diffstat (limited to 'src/main.cc')
| -rw-r--r-- | src/main.cc | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/main.cc b/src/main.cc index e86ffae3..a10ec8dd 100644 --- a/src/main.cc +++ b/src/main.cc @@ -686,16 +686,6 @@ pid_t fork_server_to_background() std::unique_ptr<UserInterface> create_local_ui(UIType ui_type) { - if (ui_type == UIType::Terminal and 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, Buffer::Flags::None); - } - auto ui = make_ui(ui_type); static SignalHandler old_handler = set_signal_handler(SIGTSTP, [](int sig) { @@ -875,6 +865,17 @@ int run_server(StringView session, StringView server_init, int exit_status = 0; try { + + if (ui_type == UIType::Terminal and 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, Buffer::Flags::None); + } + if (not server.is_daemon()) { local_client = client_manager.create_client( |
