diff --git a/doc/management.txt b/doc/management.txt index 52d3c61c4..66fecc635 100644 --- a/doc/management.txt +++ b/doc/management.txt @@ -4427,7 +4427,8 @@ Example: interactive session on the worker process by not specifying any command (i.e. "@@1" on its own line). This session can be terminated either by closing the connection or by quitting the worker process (using the "quit" - command). + command). In this case, the prompt mode of the master socket (interactive, + prompt, timed) is propagated into the worker process. Examples: # gracefully close connections and delete a server once idle (wait max 10s) diff --git a/src/cli.c b/src/cli.c index 954087140..41e8750ff 100644 --- a/src/cli.c +++ b/src/cli.c @@ -3039,11 +3039,27 @@ int pcli_find_bidir_prefix(struct stream *s, struct channel *req, char **str, co /* forward what remains */ ret = end - p; - /* without any command, simply enter the worker in interactive mode */ + /* without any command, simply enter the worker in interactive + * mode or prompt mode (the same as currently used in the master). + * The goal is to make it easy for both scripts and humans to + * enter in the same mode in the worker as they were in the master. + */ if (!ret) { - const char *cmd = "prompt\n"; - ci_insert(req, 0, cmd, strlen(cmd)); - ret += strlen(cmd); + const char *cmd; + + cmd = "prompt"; + ret += ci_insert(req, ret, cmd, strlen(cmd)); + + cmd = (s->pcli_flags & PCLI_F_PROMPT) ? " p" : " i"; + ret += ci_insert(req, ret, cmd, strlen(cmd)); + + if (s->pcli_flags & PCLI_F_TIMED) { + cmd = " timed"; + ret += ci_insert(req, ret, cmd, strlen(cmd)); + } + + cmd = "\n"; + ret += ci_insert(req, ret, cmd, strlen(cmd)); } }