MCPcopy Create free account
hub / github.com/ElementsProject/lightning / find_subdaemons_and_plugins

Function find_subdaemons_and_plugins

lightningd/lightningd.c:571–597  ·  view source on GitHub ↗

Determine the correct daemon dir. */

Source from the content-addressed store, hash-verified

569
570/* Determine the correct daemon dir. */
571static void find_subdaemons_and_plugins(struct lightningd *ld, const char *argv0)
572{
573 const char *my_path = find_my_directory(tmpctx, argv0);
574 const char *rel;
575
576 /* If we're running in-tree, all the subdaemons are with lightningd. */
577 if (has_all_subdaemons(my_path)) {
578 /* In this case, look for built-in plugins in ../plugins */
579 plugins_set_builtin_plugins_dir(ld->plugins,
580 path_join(tmpctx,
581 my_path,
582 "../plugins"));
583 ld->subdaemon_dir = tal_steal(ld, my_path);
584 return;
585 }
586
587 /* OK, we're running the installed version? But we used to allow
588 * running in an arbitrary subtree, and people still do (plus,
589 * installcheck does this). So we use relative paths here. path_rel
590 * doesn't work if the paths don't exist, so we use our own function. */
591 rel = relative(NULL, BINDIR, PKGLIBEXECDIR);
592 ld->subdaemon_dir = path_join(ld, my_path, take(rel));
593
594 rel = relative(NULL, BINDIR, PLUGINDIR);
595 plugins_set_builtin_plugins_dir(ld->plugins,
596 path_join(tmpctx, my_path, take(rel)));
597}
598
599/*~ We like to free everything on exit, so valgrind doesn't complain (valgrind
600 * is an awesome runtime memory usage detector for C and C++ programs). In

Callers 1

mainFunction · 0.85

Calls 5

find_my_directoryFunction · 0.85
has_all_subdaemonsFunction · 0.85
path_joinFunction · 0.85
relativeFunction · 0.85

Tested by

no test coverage detected