diff --git a/services/init/standard/init_cmds.c b/services/init/standard/init_cmds.c index e2abaa653d2a62eea8d8437ed922714a464c33ce..083dd58bf2bc68dc1b73e5c3e42eee5abf8f5f1d 100755 --- a/services/init/standard/init_cmds.c +++ b/services/init/standard/init_cmds.c @@ -14,6 +14,7 @@ */ #include "init_cmds.h" +#include #include #include #include @@ -180,6 +181,31 @@ static void DoExec(const struct CmdArgs *ctx) if (pid == 0) { INIT_ERROR_CHECK(ctx != NULL && ctx->argv[0] != NULL, _exit(0x7f), "DoExec: invalid arguments to exec \"%s\"", ctx->argv[0]); +#ifdef SUPPORT_PROFILER_HIDEBUG + do { + if (access("/system/lib/libhidebug.so", F_OK) != 0) { + INIT_LOGE("access failed, errno = %d\n", errno); + break; + } + void* handle = dlopen("/system/lib/libhidebug.so", RTLD_LAZY); + if (handle == NULL) { + INIT_LOGE("Failed to dlopen libhidebug.so, %s\n", dlerror()); + break; + } + bool (* initParam)(); + initParam = (bool (*)())dlsym(handle, "InitEnvironmentParam"); + if (initParam == NULL) { + INIT_LOGE("Failed to dlsym InitEnvironmentParam, %s\n", dlerror()); + dlclose(handle); + break; + } + bool ret = (*initParam)(ctx->argv[0]); + if (!ret) { + INIT_LOGE("init parameters failed.\n"); + } + dlclose(handle); + } while (0); +#endif int ret = execv(ctx->argv[0], ctx->argv); if (ret == -1) { INIT_LOGE("DoExec: execute \"%s\" failed: %d.", ctx->argv[0], errno); diff --git a/services/init/standard/init_service.c b/services/init/standard/init_service.c index cb0ca69697a6d613f8e916cdb63566eb4ffcf012..d627f4e46676f79448f7578617e493764275a7b1 100755 --- a/services/init/standard/init_service.c +++ b/services/init/standard/init_service.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "init_group_manager.h" #include "init.h" @@ -87,18 +88,29 @@ int ServiceExec(const Service *service) } INIT_CHECK_ONLY_ELOG(unsetenv("UV_THREADPOOL_SIZE") == 0, "set UV_THREADPOOL_SIZE error : %d.", errno); #ifdef SUPPORT_PROFILER_HIDEBUG - void* handle = dlopen("/system/lib/libhidebug.so", RTLD_LAZY); - if (handle == NULL) { - INIT_LOGE("Failed to dlopen libhidebug.so, %s\n", dlerror()); - return SERVICE_FAILURE; - } - bool (* initParam)(); - initParam = (bool (*)())dlsym(handle, "InitEnvironmentParam"); - if (initParam == NULL) { - INIT_LOGE("Failed to dlsym InitEnvironmentParam, %s\n", dlerror()); - return SERVICE_FAILURE; - } - (*initParam)(service->name); + do { + if (access("/system/lib/libhidebug.so", F_OK) != 0) { + INIT_LOGE("access failed, errno = %d\n", errno); + break; + } + void* handle = dlopen("/system/lib/libhidebug.so", RTLD_LAZY); + if (handle == NULL) { + INIT_LOGE("Failed to dlopen libhidebug.so, %s\n", dlerror()); + break; + } + bool (* initParam)(); + initParam = (bool (*)())dlsym(handle, "InitEnvironmentParam"); + if (initParam == NULL) { + INIT_LOGE("Failed to dlsym InitEnvironmentParam, %s\n", dlerror()); + dlclose(handle); + break; + } + bool ret = (*initParam)(service->name); + if (!ret) { + INIT_LOGE("init parameters failed.\n"); + } + dlclose(handle); + } while (0); #endif // L2 Can not be reset env if (service->extraArgs.argv != NULL && service->extraArgs.count > 0) {