diff options
| author | Maxime Coste <mawww@kakoune.org> | 2017-11-12 22:28:13 +0800 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2017-11-12 22:28:13 +0800 |
| commit | 208f9641ef8e7b5900bbbd88b2852dfa434ebfee (patch) | |
| tree | fb621a5e96cc7e595aac7c251c068077c0c7877a /src | |
| parent | 00e06302722a5b15a292b10d165dff640a3d3ce0 (diff) | |
Remote: when converting to client, suspend *after* connecting
Also, do not quit server while there is a connection being accepted
Fixes #1690
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.cc | 14 | ||||
| -rw-r--r-- | src/remote.hh | 2 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/main.cc b/src/main.cc index 6feb37b8..4671511a 100644 --- a/src/main.cc +++ b/src/main.cc @@ -503,13 +503,16 @@ std::unique_ptr<UserInterface> create_local_ui(UIType ui_type) } int run_client(StringView session, StringView client_init, - Optional<BufferCoord> init_coord, UIType ui_type) + Optional<BufferCoord> init_coord, UIType ui_type, + bool suspend) { try { EventManager event_manager; RemoteClient client{session, make_ui(ui_type), getpid(), get_env_vars(), client_init, std::move(init_coord)}; + if (suspend) + raise(SIGTSTP); while (not client.exit_status()) event_manager.handle_next_events(EventMode::Normal); return *client.exit_status(); @@ -661,7 +664,9 @@ int run_server(StringView session, StringView server_init, local_client->info_show("Welcome to Kakoune", startup_info, {}, InfoStyle::Prompt); } - while (not terminate and (not client_manager.empty() or (flags & ServerFlags::Daemon))) + while (not terminate and + (not client_manager.empty() or server.negotiating() or + (flags & ServerFlags::Daemon))) { client_manager.redraw_clients(); event_manager.handle_next_events(EventMode::Normal); @@ -980,7 +985,7 @@ int main(int argc, char* argv[]) for (auto name : files) new_files += format("edit '{}';", escape(real_path(name), "'", '\\')); - return run_client(*server_session, new_files + client_init, init_coord, ui_type); + return run_client(*server_session, new_files + client_init, init_coord, ui_type, false); } else { @@ -995,10 +1000,9 @@ int main(int argc, char* argv[]) } catch (convert_to_client_mode& convert) { - raise(SIGTSTP); return run_client(convert.session, format("try %^buffer '{}'; select '{}'^; echo converted to client only mode", - escape(convert.buffer_name, "'^", '\\'), convert.selections), {}, ui_type); + escape(convert.buffer_name, "'^", '\\'), convert.selections), {}, ui_type, true); } } } diff --git a/src/remote.hh b/src/remote.hh index b270bc47..d723713f 100644 --- a/src/remote.hh +++ b/src/remote.hh @@ -53,6 +53,8 @@ struct Server : public Singleton<Server> bool rename_session(StringView name); void close_session(bool do_unlink = true); + bool negotiating() const { return not m_accepters.empty(); } + private: class Accepter; void remove_accepter(Accepter* accepter); |
