lightningd: pass --developer down to plugins, subdaemons when it set.

They might need to know this before they do anything, so cmdline seems most
natural.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2023-09-21 15:06:26 +09:30
parent 64ab7c0c1d
commit 67a391f8d0
3 changed files with 11 additions and 4 deletions

View file

@ -1823,10 +1823,13 @@ const char *plugin_send_getmanifest(struct plugin *p, const char *cmd_id)
&& strends(p->cmd, p->plugins->ld->dev_debug_subprocess))
debug = true;
#endif
cmd = tal_arrz(tmpctx, char *, 2 + debug);
cmd = tal_arr(tmpctx, char *, 1);
cmd[0] = p->cmd;
if (debug)
cmd[1] = "--debugger";
tal_arr_expand(&cmd, "--debugger");
if (p->plugins->ld->developer)
tal_arr_expand(&cmd, "--developer");
tal_arr_expand(&cmd, NULL);
p->pid = pipecmdarr(&stdinfd, &stdoutfd, &pipecmd_preserve, cmd);
if (p->pid == -1)
return tal_fmt(p, "opening pipe: %s", strerror(errno));

View file

@ -203,6 +203,7 @@ static int subd(const char *path, const char *name,
const char *debug_subdaemon,
int *msgfd,
bool io_logging,
bool developer,
va_list *ap)
{
int childmsg[2], execfail[2];
@ -225,7 +226,7 @@ static int subd(const char *path, const char *name,
if (childpid == 0) {
size_t num_args;
char *args[] = { NULL, NULL, NULL, NULL };
char *args[] = { NULL, NULL, NULL, NULL, NULL };
int **fds = tal_arr(tmpctx, int *, 3);
int stdoutfd = STDOUT_FILENO, stderrfd = STDERR_FILENO;
@ -260,6 +261,8 @@ static int subd(const char *path, const char *name,
if (debug_subdaemon && strends(name, debug_subdaemon))
args[num_args++] = "--debugger";
#endif
if (developer)
args[num_args++] = "--developer";
execv(args[0], args);
child_errno_fail:
@ -743,6 +746,7 @@ static struct subd *new_subd(const tal_t *ctx,
/* We only turn on subdaemon io logging if we're going
* to print it: too stressful otherwise! */
log_has_io_logging(sd->log),
ld->developer,
ap);
if (sd->pid == (pid_t)-1) {
log_unusual(ld->log, "subd %s failed: %s",

View file

@ -1,7 +1,7 @@
#! /bin/sh
# If this file exists, we send that message back, then sleep.
if [ $# = 0 ] && [ -f openingd-version ]; then
if [ "$1" != "--version" ] && [ -f openingd-version ]; then
# lightningd expects us to write to stdin!
cat openingd-version >&0
sleep 10