From 14cb35f62b36b2f1aa530adb5e31c05ff1347bfc Mon Sep 17 00:00:00 2001 From: Enrico Zandomeni Borba Date: Mon, 23 Dec 2024 09:21:08 +0100 Subject: create *stdin* buffer even when daemon --- src/main.cc | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src') 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 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( -- cgit v1.2.3 From db18d02627fe9ff0f50bd558a2a6d396fb4b2649 Mon Sep 17 00:00:00 2001 From: Enrico Zandomeni Borba Date: Mon, 23 Dec 2024 09:25:38 +0100 Subject: cleanup merge --- src/main.cc | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'src') diff --git a/src/main.cc b/src/main.cc index f0c6aad1..db289aeb 100644 --- a/src/main.cc +++ b/src/main.cc @@ -689,16 +689,6 @@ pid_t fork_server_to_background() std::unique_ptr 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, AutoScroll::NotInitially); - } - auto ui = make_ui(ui_type); static SignalHandler old_handler = set_signal_handler(SIGTSTP, [](int sig) { @@ -885,7 +875,6 @@ 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 -- cgit v1.2.3 From f8c905d50b9b2cdaf6297c09fde5999e6b7eafe2 Mon Sep 17 00:00:00 2001 From: Enrico Zandomeni Borba Date: Mon, 23 Dec 2024 09:30:18 +0100 Subject: fix missing argument to create_fifo_buffer --- src/main.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.cc b/src/main.cc index db289aeb..ac9af4ca 100644 --- a/src/main.cc +++ b/src/main.cc @@ -882,7 +882,7 @@ int run_server(StringView session, StringView server_init, int tty = open("/dev/tty", O_RDONLY); dup2(tty, 0); close(tty); - create_fifo_buffer("*stdin*", fd, Buffer::Flags::None); + create_fifo_buffer("*stdin*", fd, Buffer::Flags::None, AutoScroll::NotInitially); } if (not server.is_daemon()) -- cgit v1.2.3