| 108 | } |
| 109 | |
| 110 | int SubProcess::wait() { |
| 111 | if (pid_ <= 0) |
| 112 | return exit_code_; |
| 113 | |
| 114 | if (stdout_fd_ >= 0) { |
| 115 | close(stdout_fd_); |
| 116 | stdout_fd_ = -1; |
| 117 | } |
| 118 | |
| 119 | int status; |
| 120 | if (waitpid(pid_, &status, 0) == pid_) { |
| 121 | if (WIFEXITED(status)) |
| 122 | exit_code_ = WEXITSTATUS(status); |
| 123 | else if (WIFSIGNALED(status)) |
| 124 | exit_code_ = 128 + WTERMSIG(status); |
| 125 | } |
| 126 | pid_ = -1; |
| 127 | return exit_code_; |
| 128 | } |
| 129 | |
| 130 | #else // Windows |
| 131 |
no outgoing calls