* Wait for e9patch instance to terminate. */
| 139 | * Wait for e9patch instance to terminate. |
| 140 | */ |
| 141 | static void waitBackend(const Backend &backend) |
| 142 | { |
| 143 | fclose(backend.out); |
| 144 | |
| 145 | if (backend.pid == 0) |
| 146 | return; |
| 147 | int status; |
| 148 | do |
| 149 | { |
| 150 | if (waitpid(backend.pid, &status, WUNTRACED | WCONTINUED) < 0) |
| 151 | error("failed to wait for backend process (%d): %s", |
| 152 | backend.pid, strerror(errno)); |
| 153 | } |
| 154 | while (!WIFEXITED(status) && !WIFSIGNALED(status)); |
| 155 | if (WIFEXITED(status) && WEXITSTATUS(status) != 0) |
| 156 | error("backend process (%d) exitted with a non-zero status (%d)", |
| 157 | backend.pid, WEXITSTATUS(status)); |
| 158 | else if (WIFSIGNALED(status)) |
| 159 | error("backend process (%d) killed by signal (%s)", backend.pid, |
| 160 | strsignal(WTERMSIG(status))); |
| 161 | } |
| 162 | |
| 163 | /* |
| 164 | * Open a new plugin object. |