Lines Matching refs:pid
39 static bool Exited(pid_t pid)
42 pid_t waitPid = waitpid(pid, &status, WNOHANG);
43 if (waitPid != pid) {
48 DFXLOGE("%{public}d died: Process exited with code %{public}d", pid, WEXITSTATUS(status));
50 DFXLOGE("%{public}d died: Process exited due to signal %{public}d", pid, WTERMSIG(status));
52 DFXLOGE("%{public}d died: Process finished for unknown reason", pid);
57 bool PidUtils::Quiesce(pid_t pid)
62 if (ptrace(PTRACE_GETSIGINFO, pid, 0, &si) == 0) {
71 if (ptrace(PTRACE_LISTEN, pid, 0, 0) == -1) {
78 DFXLOGE("%{public}d: Did not quiesce in 10 seconds", pid);
82 bool PidUtils::Attach(pid_t pid)
86 if (ptrace(PTRACE_ATTACH, pid, 0, 0) == 0) {
96 if (Quiesce(pid)) {
100 if (ptrace(PTRACE_DETACH, pid, 0, 0) == -1) {
106 bool PidUtils::Detach(pid_t pid)
108 if (ptrace(PTRACE_DETACH, pid, 0, 0) == -1) {
115 bool PidUtils::WaitForPidState(pid_t pid, const std::function<PidRunEnum()>& stateCheckFunc)
120 if (Attach(pid)) {
126 if (!Detach(pid)) {
129 } else if (Exited(pid)) {
135 DFXLOGE("Timed out waiting for pid %{public}d to be ready", pid);
140 bool PidUtils::WaitForPidStateAfterAttach(pid_t pid, const std::function<PidRunEnum()>& stateCheckFunc)
149 if (!Detach(pid)) {
153 } while (time(nullptr) - startTime < MAX_WAIT_TIME_SECONDS && status == PID_RUN_KEEP_GOING && Attach(pid));
155 DFXLOGE("Timed out waiting for pid %{public}d to be ready", pid);