| 294 | } |
| 295 | |
| 296 | bool SubProcess::Terminate() |
| 297 | { |
| 298 | CHECK_GT(m_pid, 1) << "Invalid pid"; |
| 299 | |
| 300 | // First we use SIGTERM to kill the process. |
| 301 | if (kill(m_pid, SIGTERM) < 0) { |
| 302 | PLOG(ERROR) << "Unable to terminate process: " << m_pid; |
| 303 | return false; |
| 304 | } |
| 305 | |
| 306 | if (TimedWaitForExit(60 * 1000)) |
| 307 | return true; |
| 308 | |
| 309 | // If can't terminate it graceful, kill it rudely. |
| 310 | if (kill(m_pid, SIGKILL) < 0) { |
| 311 | PLOG(ERROR) << "Unable to terminate process: " << m_pid; |
| 312 | return false; |
| 313 | } |
| 314 | |
| 315 | return WaitForExit(); |
| 316 | } |
| 317 | |
| 318 | bool SubProcess::SendSignal(int signal) |
| 319 | { |