diff --git a/services/init/standard/init_cmds.c b/services/init/standard/init_cmds.c index 9356e406e0c2cb1a5e330dc80d3aa80c6a2aea8e..5d7bb46948a918f92cabf92cb75b9fe76f5e38d0 100755 --- a/services/init/standard/init_cmds.c +++ b/services/init/standard/init_cmds.c @@ -184,18 +184,29 @@ static void DoExec(const struct CmdArgs *ctx) INIT_ERROR_CHECK(ctx != NULL && ctx->argv[0] != NULL, _exit(0x7f), "DoExec: invalid arguments to exec \"%s\"", ctx->argv[0]); #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; - } - bool (* initParam)(); - initParam = (bool (*)())dlsym(handle, "InitEnvironmentParam"); - if (initParam == NULL) { - INIT_LOGE("Failed to dlsym InitEnvironmentParam, %s\n", dlerror()); - return; - } - (*initParam)(ctx->argv[0]); + 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) { 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) {