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)
/* 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));
}
}