From acbe45e2946bcb8582724a2b950672e97d32c287 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 29 Nov 2012 18:56:08 +0100 Subject: [PATCH] local client forks in destructor so that the kak server detaches from terminal --- src/main.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main.cc b/src/main.cc index 0eb1df2e..5638465d 100644 --- a/src/main.cc +++ b/src/main.cc @@ -602,7 +602,21 @@ void register_registers() void create_local_client(const String& file) { Buffer* buffer = nullptr; - UserInterface* ui = new NCursesUI{}; + + class LocalNCursesUI : public NCursesUI + { + ~LocalNCursesUI() + { + if (not ClientManager::instance().empty() and fork()) + { + this->~NCursesUI(); + puts("detached from terminal\n"); + exit(0); + } + } + }; + + UserInterface* ui = new LocalNCursesUI{}; if (not file.empty()) { buffer = create_buffer_from_file(file);