mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[sessions] New option ui.sessions.fork_on_start
Default value of this bool option is 0. Nothing changes in behaviour since 0.13.1. If you set it to 1, one more process will be started. This main process will handle only interlink connections, while other processes will be slaves to it. This will allow to exit first started elinks session without breaking others.
This commit is contained in:
parent
033f15fe7b
commit
2dcac411a8
@ -1422,10 +1422,11 @@ static union option_info config_options_info[] = {
|
||||
"sessions", OPT_SORT,
|
||||
N_("Sessions settings.")),
|
||||
|
||||
INIT_OPT_BOOL("ui.sessions", N_("Keep session active"),
|
||||
"keep_session_active", 0, 0,
|
||||
N_("Keep the session active even if the last terminal "
|
||||
"exits.")),
|
||||
INIT_OPT_BOOL("ui.sessions", N_("Auto restore session"),
|
||||
"auto_restore", 0, 0,
|
||||
N_("Automatically restore the session at start.\n"
|
||||
"\n"
|
||||
"This feature requires bookmark support.")),
|
||||
|
||||
INIT_OPT_BOOL("ui.sessions", N_("Auto save session"),
|
||||
"auto_save", 0, 0,
|
||||
@ -1433,12 +1434,6 @@ static union option_info config_options_info[] = {
|
||||
"\n"
|
||||
"This feature requires bookmark support.")),
|
||||
|
||||
INIT_OPT_BOOL("ui.sessions", N_("Auto restore session"),
|
||||
"auto_restore", 0, 0,
|
||||
N_("Automatically restore the session at start.\n"
|
||||
"\n"
|
||||
"This feature requires bookmark support.")),
|
||||
|
||||
INIT_OPT_STRING("ui.sessions", N_("Auto save and restore session folder name"),
|
||||
"auto_save_foldername", 0, "Auto saved session",
|
||||
N_("Name of the bookmarks folder used for auto saving and "
|
||||
@ -1447,6 +1442,11 @@ static union option_info config_options_info[] = {
|
||||
"\n"
|
||||
"This only makes sense with bookmark support.")),
|
||||
|
||||
INIT_OPT_BOOL("ui.sessions", N_("Fork on start"),
|
||||
"fork_on_start", 0, 0,
|
||||
N_("Fork on start to let other terminals function even "
|
||||
"if the first terminal exits.")),
|
||||
|
||||
INIT_OPT_STRING("ui.sessions", N_("Homepage URI"),
|
||||
"homepage", 0, WWW_HOME_URL,
|
||||
N_("The URI to load either at startup time when no URI was "
|
||||
@ -1454,6 +1454,11 @@ static union option_info config_options_info[] = {
|
||||
"goto-url-home action. Set to \"\" if the environment "
|
||||
"variable WWW_HOME should be used as homepage URI instead.")),
|
||||
|
||||
INIT_OPT_BOOL("ui.sessions", N_("Keep session active"),
|
||||
"keep_session_active", 0, 0,
|
||||
N_("Keep the session active even if the last terminal "
|
||||
"exits.")),
|
||||
|
||||
#ifdef HAVE_STRFTIME
|
||||
INIT_OPT_STRING("ui", N_("Date format"),
|
||||
"date_format", 0, "%b %e %H:%M",
|
||||
|
@ -42,8 +42,10 @@
|
||||
#include "elinks.h"
|
||||
|
||||
#include "config/home.h"
|
||||
#include "config/options.h"
|
||||
#include "intl/gettext/libintl.h"
|
||||
#include "main/interlink.h"
|
||||
#include "main/main.h"
|
||||
#include "main/select.h"
|
||||
#include "osdep/osdep.h"
|
||||
#include "session/session.h"
|
||||
@ -520,21 +522,26 @@ init_interlink(void)
|
||||
|
||||
if (fd != -1 || remote_session_flags) return fd;
|
||||
|
||||
pid = fork();
|
||||
parse_options_again();
|
||||
|
||||
if (pid == -1) return -1;
|
||||
if (pid > 0) {
|
||||
int i;
|
||||
if (get_opt_bool("ui.sessions.fork_on_start", NULL)) {
|
||||
pid = fork();
|
||||
|
||||
for (i = 1; i <= (MAX_BIND_TRIES+2); ++i) {
|
||||
fd = connect_to_af_unix();
|
||||
if (pid == -1) return -1;
|
||||
|
||||
if (fd != -1) return fd;
|
||||
elinks_usleep(BIND_TRIES_DELAY * i);
|
||||
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;
|
||||
}
|
||||
return -1;
|
||||
close_terminal_pipes();
|
||||
}
|
||||
close_terminal_pipes();
|
||||
bind_to_af_unix();
|
||||
return -1;
|
||||
}
|
||||
|
@ -104,6 +104,24 @@ check_cwd(void)
|
||||
mem_free_if(cwd);
|
||||
}
|
||||
|
||||
void
|
||||
parse_options_again(void)
|
||||
{
|
||||
if (!init_b) {
|
||||
load_config();
|
||||
update_options_visibility();
|
||||
/* Parse commandline options again, in order to override any
|
||||
* config file options. */
|
||||
parse_options(ac - 1, av + 1, NULL);
|
||||
/* ... and re-check stdio, in order to override any command
|
||||
* line options! >;) */
|
||||
if (!remote_session_flags) {
|
||||
check_stdio(NULL);
|
||||
}
|
||||
init_b = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
@ -171,18 +189,7 @@ init(void)
|
||||
|| get_cmd_opt_bool("source")
|
||||
|| (fd = init_interlink()) == -1) {
|
||||
|
||||
load_config();
|
||||
update_options_visibility();
|
||||
/* Parse commandline options again, in order to override any
|
||||
* config file options. */
|
||||
parse_options(ac - 1, av + 1, NULL);
|
||||
/* ... and re-check stdio, in order to override any command
|
||||
* line options! >;) */
|
||||
if (!remote_session_flags) {
|
||||
check_stdio(NULL);
|
||||
}
|
||||
|
||||
init_b = 1;
|
||||
parse_options_again();
|
||||
init_modules(builtin_modules);
|
||||
}
|
||||
|
||||
@ -235,7 +242,8 @@ init(void)
|
||||
handle_trm(get_input_handle(), get_output_handle(),
|
||||
fd, fd, get_ctl_handle(), info.source, info.length,
|
||||
remote_session_flags);
|
||||
} else if (get_cmd_opt_bool("no-connect")) {
|
||||
} else if (get_cmd_opt_bool("no-connect")
|
||||
|| !get_opt_bool("ui.sessions.fork_on_start", NULL)) {
|
||||
/* Setup a master terminal */
|
||||
term = attach_terminal(get_input_handle(), get_output_handle(),
|
||||
get_ctl_handle(), info.source, info.length);
|
||||
|
@ -21,5 +21,6 @@ struct program {
|
||||
extern struct program program;
|
||||
|
||||
void shrink_memory(int);
|
||||
void parse_options_again(void);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user