| 74 | } |
| 75 | |
| 76 | bool SubProcess::is_running() const { |
| 77 | if (pid_ <= 0) |
| 78 | return false; |
| 79 | int status; |
| 80 | const pid_t result = waitpid(pid_, &status, WNOHANG); |
| 81 | if (result == pid_) { |
| 82 | if (WIFEXITED(status)) |
| 83 | const_cast<SubProcess*>(this)->exit_code_ = WEXITSTATUS(status); |
| 84 | else if (WIFSIGNALED(status)) |
| 85 | const_cast<SubProcess*>(this)->exit_code_ = 128 + WTERMSIG(status); |
| 86 | const_cast<SubProcess*>(this)->pid_ = -1; |
| 87 | return false; |
| 88 | } |
| 89 | return result == 0; |
| 90 | } |
| 91 | |
| 92 | void SubProcess::kill() { |
| 93 | if (stdout_fd_ >= 0) { |
no outgoing calls