| 759 | exited, return 0 without waiting. */ |
| 760 | |
| 761 | static pid_t |
| 762 | reap (pid_t pid) |
| 763 | { |
| 764 | int status; |
| 765 | pid_t cpid = waitpid ((pid ? pid : -1), &status, (pid ? 0 : WNOHANG)); |
| 766 | |
| 767 | if (cpid < 0) |
| 768 | error (SORT_FAILURE, errno, _("waiting for %s [-d]"), |
| 769 | quoteaf (compress_program)); |
| 770 | else if (0 < cpid && (0 < pid || delete_proc (cpid))) |
| 771 | { |
| 772 | if (! WIFEXITED (status) || WEXITSTATUS (status)) |
| 773 | error (SORT_FAILURE, 0, _("%s [-d] terminated abnormally"), |
| 774 | quoteaf (compress_program)); |
| 775 | --nprocs; |
| 776 | } |
| 777 | |
| 778 | return cpid; |
| 779 | } |
| 780 | |
| 781 | /* TEMP represents a new process; add it to the process table. Create |
| 782 | the process table the first time it's called. */ |
no test coverage detected