}
}
+ int ended = 0;
+
// Loop for as long as the process is alive
- while (waitpid(pid, status, WNOHANG) == 0) {
+ while (!ended) {
+ // If waitpid() returns non-zero, the process has ended, but we want to perform
+ // one last iteration over the loop to read any remaining content from the file
+ // descriptor buffers.
+ r = waitpid(pid, status, WNOHANG);
+ if (r)
+ ended = 1;
+
int fds = epoll_wait(epollfd, events, EPOLL_MAX_EVENTS, -1);
if (fds < 1) {
ERROR(pakfire, "epoll_wait() failed: %s\n", strerror(errno));