Commit Diff


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");
 	}
 }