From 08138487a0196fdb711088d56cec0953e8912291 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Sun, 17 May 2020 16:35:58 +0200 Subject: [PATCH] [interlink] Test commit. All terminals - slaves. Before when master terminal quit session, all slave terminal stopped to work. There is a workaround. ELinks on master terminal forks on start and becomes slave. --- src/main/interlink.c | 16 ++++++++++++++++ src/main/main.c | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/interlink.c b/src/main/interlink.c index 0ff85e74..e466a543 100644 --- a/src/main/interlink.c +++ b/src/main/interlink.c @@ -515,9 +515,25 @@ int init_interlink(void) { int fd = connect_to_af_unix(); + int pid; if (fd != -1) return fd; + pid = fork(); + + if (pid == -1) return -1; + if (pid > 0) { + int i; + + for (i = 1; i <= (MAX_BIND_TRIES+2); ++i) { + fd = connect_to_af_unix(); + + if (fd != -1) return fd; + elinks_usleep(BIND_TRIES_DELAY * i); + } + return -1; + } + close_terminal_pipes(); bind_to_af_unix(); return -1; } diff --git a/src/main/main.c b/src/main/main.c index cc0f4f13..71ac42ea 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -235,7 +235,7 @@ init(void) handle_trm(get_input_handle(), get_output_handle(), fd, fd, get_ctl_handle(), info.source, info.length, remote_session_flags); - } else { + } else if (get_cmd_opt_bool("no-connect")) { /* Setup a master terminal */ term = attach_terminal(get_input_handle(), get_output_handle(), get_ctl_handle(), info.source, info.length);