Fix wait time

This commit is contained in:
Alexander Rosenberg 2023-02-23 10:22:56 -08:00
parent c37f05bc35
commit 5400dcfc75
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730

View File

@ -4,6 +4,7 @@
#include<unistd.h> #include<unistd.h>
#include<signal.h> #include<signal.h>
#include <time.h> #include <time.h>
#include <math.h>
#ifndef NO_X #ifndef NO_X
#include<X11/Xlib.h> #include<X11/Xlib.h>
#endif #endif
@ -167,7 +168,10 @@ void statusloop() {
} }
int i = 0; int i = 0;
getcmds(-1); getcmds(-1);
const struct timespec sleeptime = { 0, interval * 1000000 }; long nsec_part = interval * 1000000;
time_t sec_part = floor(nsec_part / 1000000000.0);
nsec_part -= sec_part * 1000000000l;
const struct timespec sleeptime = { sec_part, nsec_part };
struct timespec tosleep = sleeptime; struct timespec tosleep = sleeptime;
while (statuscontinue) { while (statuscontinue) {
if (nanosleep(&tosleep, &tosleep) < 0) { if (nanosleep(&tosleep, &tosleep) < 0) {