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)
* pathc - path of the program used for handling clicks on the block */
/* 1 interval = INTERVALs seconds, INTERVALn nanoseconds */
#define INTERVALs 1
#define INTERVALn 0
/* 1 interval = <first entry> seconds, <second entry> nanoseconds */
static const struct timespec interval = { 1, 0 };
static Block blocks[] = {
/* pathu pathc interval signal */

View file

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