Write a prompt with the PID of the target or master.
It's always activated for now.

Example:
    1234>
    master>
---
 src/cli.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/cli.c b/src/cli.c
index f5935693f..1a4a92c0e 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -1620,6 +1620,18 @@ static int cli_parse_simple(char **args, char *payload, 
struct appctx *appctx, v
        return 1;
 }
 
+void pcli_write_prompt(struct stream *s)
+{
+       struct buffer *msg = get_trash_chunk();
+       struct channel *oc = si_oc(&s->si[0]);
+
+       if (s->pcli_next_pid == 0)
+               chunk_appendf(msg, "master> ");
+       else
+               chunk_appendf(msg, "%d> ", s->pcli_next_pid);
+       co_inject(oc, msg->area, msg->data);
+}
+
 
 /* The pcli_* functions are used for the CLI proxy in the master */
 
@@ -1880,7 +1892,7 @@ read_again:
                   command for this session */
                if (target_pid > -1) {
                        s->pcli_next_pid = target_pid;
-                       // TODO: pcli_reply the prompt
+                       pcli_write_prompt(s);
                } else {
                        // TODO: pcli_reply() error
                        s->pcli_next_pid = 0;
@@ -1922,6 +1934,8 @@ int pcli_wait_for_response(struct stream *s, struct 
channel *rep, int an_bit)
        if ((rep->flags & (CF_SHUTR|CF_READ_NULL))) {
                /* stream cleanup */
 
+               pcli_write_prompt(s);
+
                s->si[1].flags |= SI_FL_NOLINGER | SI_FL_NOHALF;
                si_shutr(&s->si[1]);
                si_shutw(&s->si[1]);
-- 
2.16.4


Reply via email to