| 502 | } |
| 503 | |
| 504 | static void finish_workers(struct pc_worker *workers, int num_workers) |
| 505 | { |
| 506 | int i; |
| 507 | |
| 508 | /* |
| 509 | * Close pipes before calling finish_command() to let the workers |
| 510 | * exit asynchronously and avoid spending extra time on wait(). |
| 511 | */ |
| 512 | for (i = 0; i < num_workers; i++) { |
| 513 | struct child_process *cp = &workers[i].cp; |
| 514 | if (cp->in >= 0) |
| 515 | close(cp->in); |
| 516 | if (cp->out >= 0) |
| 517 | close(cp->out); |
| 518 | } |
| 519 | |
| 520 | for (i = 0; i < num_workers; i++) { |
| 521 | int rc = finish_command(&workers[i].cp); |
| 522 | if (rc > 128) { |
| 523 | /* |
| 524 | * For a normal non-zero exit, the worker should have |
| 525 | * already printed something useful to stderr. But a |
| 526 | * death by signal should be mentioned to the user. |
| 527 | */ |
| 528 | error("checkout worker %d died of signal %d", i, rc - 128); |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | free(workers); |
| 533 | } |
| 534 | |
| 535 | static inline void assert_pc_item_result_size(int got, int exp) |
| 536 | { |
no test coverage detected