mirror of
https://gitee.com/openharmony/startup_init
synced 2024-12-11 12:47:08 +00:00
!1119 fix:kill appspawn
Merge pull request !1119 from cheng_jinsong/killappspawn
This commit is contained in:
commit
91ca5757f8
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user