Improved interval handling

This commit is contained in:
Ashish Kumar Yadav 2021-04-04 13:33:06 +05:30
parent 894ca1e544
commit c265691e73
2 changed files with 4 additions and 5 deletions

View file

@ -37,9 +37,8 @@ static const char delimiter[] = { ' ', ' ', ' ', DELIMITERENDCHAR };
one newline character at the end) one newline character at the end)
* pathc - path of the program used for handling clicks on the block */ * pathc - path of the program used for handling clicks on the block */
/* 1 interval = INTERVALs seconds, INTERVALn nanoseconds */ /* 1 interval = <first entry> seconds, <second entry> nanoseconds */
#define INTERVALs 1 static const struct timespec interval = { 1, 0 };
#define INTERVALn 0
static Block blocks[] = { static Block blocks[] = {
/* pathu pathc interval signal */ /* pathu pathc interval signal */

View file

@ -139,7 +139,7 @@ statusloop()
updateblock(block, NILL); updateblock(block, NILL);
updatestatus(); updatestatus();
sigprocmask(SIG_UNBLOCK, &blocksigmask, NULL); sigprocmask(SIG_UNBLOCK, &blocksigmask, NULL);
t.tv_sec = INTERVALs, t.tv_nsec = INTERVALn; t = interval;
while (nanosleep(&t, &t) == -1) while (nanosleep(&t, &t) == -1)
if (errno != EINTR) { if (errno != EINTR) {
perror("statusloop - nanosleep"); perror("statusloop - nanosleep");
@ -153,7 +153,7 @@ statusloop()
updateblock(block, NILL); updateblock(block, NILL);
updatestatus(); updatestatus();
sigprocmask(SIG_UNBLOCK, &blocksigmask, NULL); sigprocmask(SIG_UNBLOCK, &blocksigmask, NULL);
t.tv_sec = INTERVALs, t.tv_nsec = INTERVALn; t = interval;
while (nanosleep(&t, &t) == -1); while (nanosleep(&t, &t) == -1);
} }
} }