commit 71bf58261180540753b6cdd0bcbf2853f2152f1f from: Sven M. Hallberg <pesco@khjk.org> date: Sun Jan 08 11:45:42 2023 UTC do nanosleep properly Also fixes a missing 0 in the timespec. Oops. commit - 2c2a629300a971043a6fc54136a390d26e2e9ee6 commit + 71bf58261180540753b6cdd0bcbf2853f2152f1f blob - 34735651bf862c735090f4a6682c53469d6466e6 blob + a126bcfcaf9cc7b1530ccc8a71bd68630f0e36d4 --- mc5000.c +++ mc5000.c @@ -8,6 +8,7 @@ */ #include <assert.h> +#include <errno.h> #include <stdio.h> #include <stdint.h> /* uint8_t */ #include <stdlib.h> /* exit */ @@ -274,8 +275,10 @@ write_byte(uint8_t x, FILE *f) fputc(x, f); if (f == devf) { - struct timespec ts = {0, 10 * 100000L}; /* 10 ms */ - nanosleep(&ts, NULL); // XXX could be interrupted + struct timespec ts = {0, 10 * 1000000L}; /* 10 ms */ + while (nanosleep(&ts, &ts) == -1) + if (errno != EINTR) + err(1, "nanosleep"); } }