lightningd: clean up properly if we fail to exec plugin.

Reported-by: @niftynei
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: Plugins: we clean up properly if a plugin fails to start, and we don't kill all processes if it's from `plugin startdir`.
This commit is contained in:
Rusty Russell
2023-08-17 19:50:15 +09:30
parent 04ddb4af8d
commit f4e2d9a0ae
3 changed files with 6 additions and 5 deletions

View File

@@ -74,13 +74,16 @@ plugin_dynamic_start(struct plugin_command *pcmd, const char *plugin_path,
"%s: %s", plugin_path,
errno ? strerror(errno) : "already registered");
/* This will come back via plugin_cmd_killed or plugin_cmd_succeeded */
err = plugin_send_getmanifest(p, pcmd->cmd->id);
if (err)
if (err) {
/* Free plugin with cmd (it owns buffer and params!) */
tal_steal(pcmd->cmd, p);
return command_fail(pcmd->cmd, PLUGIN_ERROR,
"%s: %s",
plugin_path, err);
}
/* This will come back via plugin_cmd_killed or plugin_cmd_succeeded */
return command_still_pending(pcmd->cmd);
}