Lines Matching refs:pid
113 pid_t pid = process->pid(); in StartProcess() local
116 pid, in StartProcess()
119 pid))); in StartProcess()
125 watched_processes_.emplace(pid, exit_callback); in StartProcess()
126 return pid; in StartProcess()
162 pid_t pid; in StartProcessInMinijailWithPipes() local
164 jail, args, &pid, stdin_fd, stdout_fd, stderr_fd)) { in StartProcessInMinijailWithPipes()
171 pid, in StartProcessInMinijailWithPipes()
174 pid))); in StartProcessInMinijailWithPipes()
176 watched_processes_.emplace(pid, exit_callback); in StartProcessInMinijailWithPipes()
177 return pid; in StartProcessInMinijailWithPipes()
180 bool ProcessManager::StopProcess(pid_t pid) { in StopProcess() argument
181 SLOG(this, 2) << __func__ << "(" << pid << ")"; in StopProcess()
183 if (pending_termination_processes_.find(pid) != in StopProcess()
185 LOG(ERROR) << "Process " << pid << " already being stopped."; in StopProcess()
189 if (watched_processes_.find(pid) == watched_processes_.end()) { in StopProcess()
190 LOG(ERROR) << "Process " << pid << " not being watched"; in StopProcess()
195 watched_processes_.erase(pid); in StopProcess()
198 return TerminateProcess(pid, false); in StopProcess()
201 bool ProcessManager::StopProcessAndBlock(pid_t pid) { in StopProcessAndBlock() argument
202 SLOG(this, 2) << __func__ << "(" << pid << ")"; in StopProcessAndBlock()
204 auto terminated_process = pending_termination_processes_.find(pid); in StopProcessAndBlock()
207 LOG(INFO) << "Process " << pid << " already being stopped."; in StopProcessAndBlock()
211 if (watched_processes_.find(pid) == watched_processes_.end()) { in StopProcessAndBlock()
212 LOG(ERROR) << "Process " << pid << " not being watched"; in StopProcessAndBlock()
217 watched_processes_.erase(pid); in StopProcessAndBlock()
223 process_reaper_.ForgetChild(pid); in StopProcessAndBlock()
227 if (KillProcessWithTimeout(pid, false) || in StopProcessAndBlock()
228 KillProcessWithTimeout(pid, true)) { in StopProcessAndBlock()
233 LOG(ERROR) << "Timeout waiting for process " << pid << " to be killed."; in StopProcessAndBlock()
238 bool ProcessManager::KillProcessWithTimeout(pid_t pid, bool kill_signal) { in KillProcessWithTimeout() argument
239 SLOG(this, 2) << __func__ << "(pid: " << pid << ")"; in KillProcessWithTimeout()
242 if (KillProcess(pid, kill_signal ? SIGKILL : SIGTERM, &killed)) { in KillProcessWithTimeout()
250 if (WaitpidWithTimeout(pid, kWaitpidPollInitialIntervalMilliseconds, in KillProcessWithTimeout()
259 bool ProcessManager::KillProcess(pid_t pid, int signal, bool* killed) { in KillProcess() argument
260 SLOG(this, 2) << __func__ << "(pid: " << pid << ")"; in KillProcess()
262 if (kill(pid, signal) < 0) { in KillProcess()
264 SLOG(this, 2) << "Process " << pid << " has exited."; in KillProcess()
268 PLOG(ERROR) << "Failed to send " << signal <<"signal to process " << pid; in KillProcess()
274 bool ProcessManager::WaitpidWithTimeout(pid_t pid, in WaitpidWithTimeout() argument
278 SLOG(this, 2) << __func__ << "(pid: " << pid << ")"; in WaitpidWithTimeout()
281 if (waitpid(pid, NULL, WNOHANG) == pid) { in WaitpidWithTimeout()
293 pid_t pid, in UpdateExitCallback() argument
295 SLOG(this, 2) << __func__ << "(pid: " << pid << ")"; in UpdateExitCallback()
297 const auto process_entry = watched_processes_.find(pid); in UpdateExitCallback()
299 LOG(ERROR) << "Process " << pid << " not being watched"; in UpdateExitCallback()
307 void ProcessManager::OnProcessExited(pid_t pid, const siginfo_t& info) { in OnProcessExited() argument
308 SLOG(this, 2) << __func__ << "(pid: " << pid << ")"; in OnProcessExited()
311 auto watched_process = watched_processes_.find(pid); in OnProcessExited()
320 auto terminated_process = pending_termination_processes_.find(pid); in OnProcessExited()
327 NOTREACHED() << "Unknown process " << pid << " status " << info.si_status; in OnProcessExited()
330 void ProcessManager::ProcessTerminationTimeoutHandler(pid_t pid, in ProcessTerminationTimeoutHandler() argument
332 SLOG(this, 2) << __func__ << "(pid: " << pid << ")"; in ProcessTerminationTimeoutHandler()
334 CHECK(pending_termination_processes_.find(pid) != in ProcessTerminationTimeoutHandler()
336 pending_termination_processes_.erase(pid); in ProcessTerminationTimeoutHandler()
339 LOG(ERROR) << "Timeout waiting for process " << pid << " to be killed."; in ProcessTerminationTimeoutHandler()
344 TerminateProcess(pid, true); in ProcessTerminationTimeoutHandler()
347 bool ProcessManager::TerminateProcess(pid_t pid, bool kill_signal) { in TerminateProcess() argument
349 << "(pid: " << pid << ", " in TerminateProcess()
354 if (!KillProcess(pid, signal, &killed)) { in TerminateProcess()
364 pid, in TerminateProcess()
368 pending_termination_processes_.emplace(pid, std::move(termination_callback)); in TerminateProcess()