aboutsummaryrefslogtreecommitdiff
path: root/runit/runsv.c
diff options
context:
space:
mode:
Diffstat (limited to 'runit/runsv.c')
-rw-r--r--runit/runsv.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/runit/runsv.c b/runit/runsv.c
index 36d85101e..ecab8cdf5 100644
--- a/runit/runsv.c
+++ b/runit/runsv.c
@@ -58,11 +58,19 @@ static void gettimeofday_ns(struct timespec *ts)
58#else 58#else
59static void gettimeofday_ns(struct timespec *ts) 59static void gettimeofday_ns(struct timespec *ts)
60{ 60{
61 BUILD_BUG_ON(sizeof(struct timeval) != sizeof(struct timespec)); 61 if (sizeof(struct timeval) == sizeof(struct timespec)
62 BUILD_BUG_ON(sizeof(((struct timeval*)ts)->tv_usec) != sizeof(ts->tv_nsec)); 62 && sizeof(((struct timeval*)ts)->tv_usec) == sizeof(ts->tv_nsec)
63 /* Cheat */ 63 ) {
64 gettimeofday((void*)ts, NULL); 64 /* Cheat */
65 ts->tv_nsec *= 1000; 65 xgettimeofday((void*)ts);
66 ts->tv_nsec *= 1000;
67 } else {
68 /* For example, musl has "incompatible" layouts */
69 struct timeval tv;
70 xgettimeofday(&tv);
71 ts->tv_sec = tv.tv_sec;
72 ts->tv_nsec = tv.tv_usec * 1000;
73 }
66} 74}
67#endif 75#endif
68 76
@@ -651,7 +659,7 @@ int runsv_main(int argc UNUSED_PARAM, char **argv)
651 gettimeofday_ns(&svd[0].start); 659 gettimeofday_ns(&svd[0].start);
652 update_status(&svd[0]); 660 update_status(&svd[0]);
653 if (LESS(svd[0].start.tv_sec, deadline)) 661 if (LESS(svd[0].start.tv_sec, deadline))
654 sleep(1); 662 sleep1();
655 } 663 }
656 if (haslog) { 664 if (haslog) {
657 if (child == svd[1].pid) { 665 if (child == svd[1].pid) {
@@ -664,7 +672,7 @@ int runsv_main(int argc UNUSED_PARAM, char **argv)
664 gettimeofday_ns(&svd[1].start); 672 gettimeofday_ns(&svd[1].start);
665 update_status(&svd[1]); 673 update_status(&svd[1]);
666 if (LESS(svd[1].start.tv_sec, deadline)) 674 if (LESS(svd[1].start.tv_sec, deadline))
667 sleep(1); 675 sleep1();
668 } 676 }
669 } 677 }
670 } /* for (;;) */ 678 } /* for (;;) */