fix delay in a cleaner way
This commit is contained in:
parent
6cab2d5719
commit
862d158b7c
@ -75,7 +75,7 @@ static void usage(void);
|
|||||||
|
|
||||||
char *argv0;
|
char *argv0;
|
||||||
char concat[];
|
char concat[];
|
||||||
static unsigned short int delay;
|
static unsigned short int delay = 0;
|
||||||
static unsigned short int done;
|
static unsigned short int done;
|
||||||
static unsigned short int dflag, oflag;
|
static unsigned short int dflag, oflag;
|
||||||
static Display *dpy;
|
static Display *dpy;
|
||||||
@ -164,7 +164,7 @@ cpu_perc(void)
|
|||||||
fscanf(fp, "%*s %Lf %Lf %Lf %Lf", &a[0], &a[1], &a[2], &a[3]);
|
fscanf(fp, "%*s %Lf %Lf %Lf %Lf", &a[0], &a[1], &a[2], &a[3]);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
delay = (UPDATE_INTERVAL - (UPDATE_INTERVAL - 1));
|
delay++;
|
||||||
sleep(delay);
|
sleep(delay);
|
||||||
|
|
||||||
fp = fopen("/proc/stat", "r");
|
fp = fopen("/proc/stat", "r");
|
||||||
@ -829,9 +829,14 @@ main(int argc, char *argv[])
|
|||||||
* subtract delay time spend in function
|
* subtract delay time spend in function
|
||||||
* calls from the actual global delay time
|
* calls from the actual global delay time
|
||||||
*/
|
*/
|
||||||
|
if ((UPDATE_INTERVAL - delay) <= 0) {
|
||||||
|
delay = 0;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
sleep(UPDATE_INTERVAL - delay);
|
sleep(UPDATE_INTERVAL - delay);
|
||||||
delay = 0;
|
delay = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!oflag) {
|
if (!oflag) {
|
||||||
set_status(NULL);
|
set_status(NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user