From 4f1c78d3fa60c2df57e0f70be30c268e3df8a38a Mon Sep 17 00:00:00 2001 From: zhanghang133 Date: Thu, 5 Sep 2024 21:37:14 +0800 Subject: [PATCH] =?UTF-8?q?cherry=20pick=2020425b2=20from=20https://gitee.?= =?UTF-8?q?com/zhanghang133/drivers=5Fhdf=5Fcore/pulls/2272=20camera=5Fhos?= =?UTF-8?q?t=E8=BF=9B=E7=A8=8B=E9=80=80=E5=87=BA=E6=97=B6=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=5Fexit(0)=E5=87=BD=E6=95=B0=E9=80=80=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghang133 --- adapter/uhdf2/host/devhost.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/adapter/uhdf2/host/devhost.c b/adapter/uhdf2/host/devhost.c index ff633388b..0e782eda6 100644 --- a/adapter/uhdf2/host/devhost.c +++ b/adapter/uhdf2/host/devhost.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "securec.h" #include "parameter.h" @@ -143,40 +144,40 @@ static void SetMallopt(int argc, char **argv) return; } +static void SetHostProperties(int argc, char **argv, const char *hostName) +{ + SetProcTitle(argv, hostName); + StartMemoryHook(hostName); + if ((strcmp(argv[DEVHOST_PROCESS_PRI_POS], INVALID_PRIORITY) != 0) && + (strcmp(argv[DEVHOST_THREAD_PRI_POS], INVALID_PRIORITY) != 0)) { + HdfSetProcPriority(argv); + } + if (argc > DEVHOST_MIN_INPUT_PARAM_NUM) { + SetMallopt(argc, argv); + } +} + int main(int argc, char **argv) { if (argc < DEVHOST_MIN_INPUT_PARAM_NUM) { HDF_LOGE("Devhost main parameter error, argc: %{public}d", argc); return HDF_ERR_INVALID_PARAM; } - prctl(PR_SET_PDEATHSIG, SIGKILL); // host process should exit with devmgr process - int hostId = 0; if (!HdfStringToInt(argv[DEVHOST_INPUT_PARAM_HOSTID_POS], &hostId)) { HDF_LOGE("Devhost main parameter error, argv[1]: %{public}s", argv[DEVHOST_INPUT_PARAM_HOSTID_POS]); return HDF_ERR_INVALID_PARAM; } - const char *hostName = argv[DEVHOST_HOST_NAME_POS]; HDF_LOGI("hdf device host %{public}s %{public}d start", hostName, hostId); - SetProcTitle(argv, hostName); - StartMemoryHook(hostName); - if ((strcmp(argv[DEVHOST_PROCESS_PRI_POS], INVALID_PRIORITY) != 0) && - (strcmp(argv[DEVHOST_THREAD_PRI_POS], INVALID_PRIORITY) != 0)) { - HdfSetProcPriority(argv); - } - if (argc > DEVHOST_MIN_INPUT_PARAM_NUM) { - SetMallopt(argc, argv); - } - + SetHostProperties(argc, argv, hostName); struct IDevHostService *instance = DevHostServiceNewInstance(hostId, hostName); if (instance == NULL || instance->StartService == NULL) { HDF_LOGE("DevHostServiceGetInstance fail"); return HDF_ERR_INVALID_OBJECT; } HDF_LOGD("create IDevHostService of %{public}s success", hostName); - DevHostDumpInit(); HDF_LOGD("%{public}s start device service begin", hostName); int status = instance->StartService(instance); @@ -186,7 +187,6 @@ int main(int argc, char **argv) DevHostDumpDeInit(); return status; } - HdfPowerManagerInit(); struct DevHostServiceFull *fullService = (struct DevHostServiceFull *)instance; struct HdfMessageLooper *looper = &fullService->looper; @@ -194,9 +194,11 @@ int main(int argc, char **argv) HDF_LOGI("%{public}s start loop", hostName); looper->Start(looper); } - HdfPowerManagerExit(); DevHostDumpDeInit(); - HDF_LOGI("hdf device host %{public}s %{public}d exit", hostName, hostId); + HDF_LOGI("hdf device host %{public}s %{public}d %{public}d exit", hostName, hostId, status); + if (strcmp(hostName, "camera_host") == 0) { + _exit(status); + } return status; } -- Gitee