noise: Fix freewheel generator's use of setitimer(2).
[u/mdw/catacomb] / noise.c
diff --git a/noise.c b/noise.c
index 9088930..c122506 100644 (file)
--- a/noise.c
+++ b/noise.c
@@ -390,7 +390,8 @@ int noise_freewheel(rand_pool *r)
 
 done:
   signal(SIGALRM, sigal);
-  TV_SUB(&oitv.it_value, &oitv.it_value, &itv.it_value);
+  if (oitv.it_value.tv_sec || oitv.it_value.tv_usec)
+    TV_SUB(&oitv.it_value, &oitv.it_value, &itv.it_value);
   setitimer(ITIMER_REAL, &oitv, 0);
   return (rc);
 }