提交 b64ed295 编写于 作者: C cheng_jinsong

fix bug for kill appspawn

Signed-off-by: Ncheng_jinsong <chengjinsong2@huawei.com>
上级 2e4db6ee
......@@ -63,6 +63,7 @@ void LoadAccessTokenId(void);
Service *AddService(const char *name);
void DumpServiceHookExecute(const char *name, const char *info);
void ProcessControlFd(uint16_t type, const char *serviceCmd, const void *context);
int GetKillServiceSig(const char *name);
#ifdef __cplusplus
#if __cplusplus
}
......
......@@ -219,7 +219,7 @@ static void DoReset(const struct CmdArgs *ctx)
return;
}
if (service->pid > 0) {
if (kill(service->pid, SIGKILL) != 0) {
if (kill(service->pid, GetKillServiceSig(ctx->argv[0])) != 0) {
INIT_LOGE("stop service %s pid %d failed! err %d.", service->name, service->pid, errno);
return;
}
......
......@@ -432,7 +432,7 @@ int ServiceStop(Service *service)
if (IsServiceWithTimerEnabled(service)) {
ServiceStopTimer(service);
}
INIT_ERROR_CHECK(kill(service->pid, SIGKILL) == 0, return SERVICE_FAILURE,
INIT_ERROR_CHECK(kill(service->pid, GetKillServiceSig(service->name)) == 0, return SERVICE_FAILURE,
"stop service %s pid %d failed! err %d.", service->name, service->pid, errno);
NotifyServiceChange(service, SERVICE_STOPPING);
INIT_LOGI("stop service %s, pid %d.", service->name, service->pid);
......
......@@ -1091,3 +1091,11 @@ void LoadAccessTokenId(void)
{
GetAccessToken();
}
int GetKillServiceSig(const char *name)
{
if (strcmp(name, "appspawn") == 0 || strcmp(name, "nwebspawn") == 0) {
return SIGTERM;
}
return SIGKILL;
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册