+ struct timespec next, now, diff;
+ clock_gettime(CLOCK_MONOTONIC, &next);
+ int completed = 0;
+ while (!finish_flag && (opt.count == 0 || completed < opt.count)) {
+ struct pollfd pfd[1];
+ pfd[0].fd = completion_pipe[0];
+ pfd[0].events = POLLIN;
+ ret = poll(pfd, 1, 100);
+ if (ret == -1 && !INTERRUPTED_SYSCALL(errno))
+ error(1, errno, "poll main");
+ if (ret > 0 && (pfd[0].revents & POLLIN)) {
+ struct msg_info *mi;
+ int ret;
+ ret = read(completion_pipe[0], &mi, sizeof(mi));
+ if (ret < sizeof(mi))
+ error(1, errno, "read completion returned %d", ret);
+ if (opt.file)
+ msg_info_print(opt.file, mi);
+ msg_info_free(mi);
+ completed++;
+ }
+
+ clock_gettime(CLOCK_MONOTONIC, &now);
+ if (timespec_subtract(&diff, &next, &now)) {
+ printf("\rMessage %d", count);
+ fflush(stdout);
+ next.tv_nsec += 100000000;
+ while (next.tv_nsec >= 1000000000) {
+ next.tv_nsec -= 1000000000;
+ next.tv_sec++;
+ }
+ }
+ }
+ printf("\rMessage %d\n", count);