Lines Matching defs:pid
64 static void WaitChildDied(pid_t pid);
100 pid_t pid = appInfo->pid;
101 APPSPAWN_LOGI("kill %{public}s pid: %{public}d", appInfo->name, appInfo->pid);
107 if (pid > 0 && kill(pid, SIGKILL) != 0) {
108 APPSPAWN_LOGE("unable to kill process, pid: %{public}d errno: %{public}d", pid, errno);
117 APPSPAWN_LOGI("kill %{public}s pid: %{public}d", appInfo->name, appInfo->pid);
119 KillAndWaitStatus(appInfo->pid, SIGTERM, &exitStatus);
127 APPSPAWN_LOGI("kill %{public}s pid: %{public}d", appInfo->name, appInfo->pid);
129 KillAndWaitStatus(appInfo->pid, SIGTERM, &exitStatus);
142 static inline void DumpStatus(const char *appName, pid_t pid, int status)
145 APPSPAWN_LOGW("%{public}s with pid %{public}d exit with signal:%{public}d", appName, pid, WTERMSIG(status));
148 APPSPAWN_LOGW("%{public}s with pid %{public}d exit with code:%{public}d", appName, pid, WEXITSTATUS(status));
152 static void HandleDiedPid(pid_t pid, uid_t uid, int status)
155 if (pid == content->reservedPid) {
156 APPSPAWN_LOGW("HandleDiedPid with reservedPid %{public}d", pid);
159 AppSpawnedProcess *appInfo = GetSpawnedProcess(pid);
160 if (appInfo == NULL) { // If an exception occurs during app spawning, kill pid, return failed
161 WaitChildDied(pid);
162 DumpStatus("unknown", pid, status);
168 DumpStatus(appInfo->name, pid, status);
175 APPSPAWN_LOGW("Current process of death is nwebspawn, pid = %{public}d, restart appspawn", pid);
187 case SIGCHLD: { // delete pid from app map
188 pid_t pid;
190 while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
193 HandleDiedPid(pid, siginfo->ssi_uid, status);
217 APPSPAWN_LOGI("Kill process, pid: %{public}d app: %{public}s", ctx->pid, GetProcessName(ctx));
218 if (ctx->pid > 0 && kill(ctx->pid, SIGKILL) != 0) {
219 APPSPAWN_LOGE("unable to kill process, pid: %{public}d errno: %{public}d", ctx->pid, errno);
261 AppSpawnedProcess *appInfo = GetSpawnedProcess(msg->result.pid);
265 APPSPAWN_LOGI("SendMessageComplete connectionId: %{public}u result %{public}d app %{public}s pid %{public}d",
266 connection->connectionId, LE_GetSendResult(handle), appInfo->name, msg->result.pid);
267 if (LE_GetSendResult(handle) != 0 && msg->result.pid > 0) {
268 kill(msg->result.pid, SIGKILL);
272 static int SendResponse(const AppSpawnConnection *connection, const AppSpawnMsg *msg, int result, pid_t pid)
274 APPSPAWN_LOGV("SendResponse connectionId: %{public}u result: 0x%{public}x pid: %{public}d",
275 connection->connectionId, result, pid);
283 buffer->result.pid = pid;
564 pid_t pid = *(pid_t *)context;
565 APPSPAWN_LOGI("Kill process group with process group id %{public}d, pidFd %{public}d", pid, fd);
566 AppSpawnedProcess *appInfo = GetSpawnedProcess(pid);
568 APPSPAWN_LOGW("Cannot get app info by bundle name: %{public}d", pid);
575 static int OpenPidFd(pid_t pid, unsigned int flags)
577 return syscall(SYS_pidfd_open, pid, flags);
582 if (property->pid <= 0) {
583 APPSPAWN_LOGW("Invalid child process pid, skip watch");
590 AppSpawnedProcess *appInfo = GetSpawnedProcess(property->pid);
592 APPSPAWN_LOGW("Cannot get app info of pid %{public}d", property->pid);
595 int fd = OpenPidFd(property->pid, PIDFD_NONBLOCK); // PIDFD_NONBLOCK since Linux kernel 5.10
597 APPSPAWN_LOGW("Failed to open pid fd for app: %{public}s, err = %{public}d",
601 APPSPAWN_LOGI("watch app process pid %{public}d, pidFd %{public}d", property->pid, fd);
611 *appPid = property->pid;
617 APPSPAWN_LOGW("Failed to watch child pid fd, pid is %{public}d", property->pid);
641 return APPSPAWN_SYSTEM_ERROR, "Failed to watch child %{public}d", property->pid);
653 APPSPAWN_LOGE("Failed to watch child %{public}d", property->pid);
917 ret = RunAppSpawnProcessMsg(GetAppSpawnContent(), &property->client, &property->pid);
925 kill(property->pid, SIGKILL);
935 static void WaitChildDied(pid_t pid)
937 AppSpawningCtx *property = GetAppSpawningCtxByPid(pid);
939 APPSPAWN_LOGI("Child process %{public}s fail \'child crash \'pid %{public}d appId: %{public}d",
940 GetProcessName(property), property->pid, property->client.id);
961 APPSPAWN_LOGI("Child process %{public}s fail \'wait child timeout \'pid %{public}d appId: %{public}d",
962 GetProcessName(property), property->pid, property->client.id);
963 if (property->pid > 0) {
965 DumpSpawnStack(property->pid);
967 kill(property->pid, SIGKILL);
977 APPSPAWN_LOGI("Child process %{public}s success pid %{public}d appId: %{public}d result: %{public}d",
978 GetProcessName(property), property->pid, property->client.id, result);
982 SendResponse(property->message->connection, &property->message->msgHeader, result, property->pid);
1006 AppSpawnedProcess *appInfo = AddSpawnedProcess(property->pid, GetBundleName(property), isDebuggable);
1035 SendResponse(property->message->connection, &property->message->msgHeader, result, property->pid);
1299 pid_t pid = 0;
1305 pid = NWebSpawnLaunch();
1306 if (pid == 0) {
1342 AddSpawnedProcess(pid, NWEBSPAWN_SERVER_NAME, false);
1541 APPSPAWN_STATIC int AppspawpnDevicedebugKill(int pid, cJSON *args)
1549 AppSpawnedProcess *appInfo = GetSpawnedProcess(pid);
1551 APPSPAWN_LOGE("appspawn devicedebug get app info unsuccess, pid=%{public}d", pid);
1556 APPSPAWN_LOGE("appspawn devicedebug process is not debuggable, pid=%{public}d", pid);
1560 APPSPAWN_LOGI("appspawn devicedebug debugable=%{public}d, pid=%{public}d, signal=%{public}d",
1561 appInfo->isDebuggable, pid, signal->valueint);
1563 if (kill(pid, signal->valueint) != 0) {
1564 APPSPAWN_LOGE("appspawn devicedebug unable to kill process, pid: %{public}d ret %{public}d", pid, errno);
1571 APPSPAWN_STATIC int AppspawnDevicedebugDeal(const char* op, int pid, cJSON *args)
1574 return AppspawpnDevicedebugKill(pid, args);
1634 SendResponse(connection, msg, ret == 0 ? result.result : ret, result.pid);