Hi, This keeps the progress printouts from stalling in the pathological case.
We were also missing <sys/time.h> for gettimeofday(2). -- Scott Cheloha Index: usr.bin/cdio/mmc.c =================================================================== RCS file: /cvs/src/usr.bin/cdio/mmc.c,v retrieving revision 1.30 diff -u -p -r1.30 mmc.c --- usr.bin/cdio/mmc.c 16 Jan 2015 06:40:06 -0000 1.30 +++ usr.bin/cdio/mmc.c 10 Sep 2017 20:37:45 -0000 @@ -18,6 +18,7 @@ #include <sys/limits.h> #include <sys/types.h> #include <sys/scsiio.h> +#include <sys/time.h> #include <sys/param.h> /* setbit, isset */ #include <scsi/cd.h> #include <scsi/scsi_all.h> @@ -27,6 +28,7 @@ #include <fcntl.h> #include <stdio.h> #include <string.h> +#include <time.h> #include <unistd.h> #include "extern.h" @@ -433,7 +435,7 @@ writetao(struct track_head *thp) int writetrack(struct track_info *tr, int track) { - struct timeval tv, otv, atv; + struct timespec tv, otv, atv; u_char databuf[65536], nblk; u_int end_lba, lba, tmp; scsireq_t scr; @@ -451,9 +453,9 @@ writetrack(struct track_info *tr, int tr scr.senselen = SENSEBUFLEN; scr.flags = SCCMD_ESCAPE|SCCMD_WRITE; - timerclear(&otv); + timespecclear(&otv); atv.tv_sec = 1; - atv.tv_usec = 0; + atv.tv_nsec = 0; if (get_nwa(&lba) != SCCMD_OK) { warnx("cannot get next writable address"); @@ -500,13 +502,13 @@ again: } lba += nblk; - gettimeofday(&tv, NULL); - if (lba == end_lba || timercmp(&tv, &otv, >)) { + clock_gettime(CLOCK_MONOTONIC, &tv); + if (lba == end_lba || timespeccmp(&tv, &otv, >)) { fprintf(stderr, "\rtrack %02d '%c' %08u/%08u %3d%%", track, tr->type, lba, end_lba, 100 * lba / end_lba); - timeradd(&tv, &atv, &otv); + timespecadd(&tv, &atv, &otv); } tmp = htobe32(lba); /* update lba in cdb */ memcpy(&scr.cmd[2], &tmp, sizeof(tmp)); Index: usr.bin/cdio/rip.c =================================================================== RCS file: /cvs/src/usr.bin/cdio/rip.c,v retrieving revision 1.16 diff -u -p -r1.16 rip.c --- usr.bin/cdio/rip.c 20 Aug 2015 22:32:41 -0000 1.16 +++ usr.bin/cdio/rip.c 10 Sep 2017 20:37:45 -0000 @@ -23,6 +23,7 @@ #include <sys/ioctl.h> #include <sys/scsiio.h> #include <sys/stat.h> +#include <sys/time.h> #include <scsi/scsi_all.h> #include <scsi/scsi_disk.h> @@ -37,6 +38,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <time.h> #include <unistd.h> #include "extern.h" @@ -362,7 +364,7 @@ read_data_sector(u_int32_t lba, u_char * int read_track(struct track *ti) { - struct timeval tv, otv, atv; + struct timespec tv, otv, atv; u_int32_t i, blksize, n_sec; u_char *sec; int error; @@ -373,18 +375,18 @@ read_track(struct track *ti) if (sec == NULL) return (-1); - timerclear(&otv); + timespecclear(&otv); atv.tv_sec = 1; - atv.tv_usec = 0; + atv.tv_nsec = 0; for (i = 0; i < n_sec; ) { - gettimeofday(&tv, NULL); - if (timercmp(&tv, &otv, >)) { + clock_gettime(CLOCK_MONOTONIC, &tv); + if (timespeccmp(&tv, &otv, >)) { fprintf(stderr, "\rtrack %u '%c' %08u/%08u %3u%%", ti->track, (ti->isaudio) ? 'a' : 'd', i, n_sec, 100 * i / n_sec); - timeradd(&tv, &atv, &otv); + timespecadd(&tv, &atv, &otv); } error = read_data_sector(i + ti->start_lba, sec, blksize);