| 428 |
|
extern int optind; |
| 429 |
|
int c; |
| 430 |
|
|
| 431 |
+ |
time_t last_update = 0; |
| 432 |
+ |
|
| 433 |
|
WINDOW *window; |
| 434 |
|
|
| 435 |
|
extern int errno; |
| 454 |
|
fprintf(stderr, "Time must be 1 second or greater\n"); |
| 455 |
|
exit(1); |
| 456 |
|
} |
| 455 |
– |
delay--; |
| 457 |
|
break; |
| 458 |
|
case 'v': |
| 459 |
|
version_num(argv[0]); |
| 463 |
|
usage(argv[0]); |
| 464 |
|
return 1; |
| 465 |
|
break; |
| 465 |
– |
|
| 466 |
|
} |
| 467 |
|
} |
| 468 |
|
|
| 484 |
|
display_headings(); |
| 485 |
|
|
| 486 |
|
for(;;){ |
| 487 |
+ |
time_t now; |
| 488 |
|
int ch = getch(); |
| 489 |
+ |
|
| 490 |
|
if (ch == 'q'){ |
| 491 |
< |
endwin(); |
| 490 |
< |
return 0; |
| 491 |
> |
break; |
| 492 |
|
} |
| 493 |
|
|
| 494 |
< |
get_stats(); |
| 494 |
> |
/* To keep the numbers slightly accurate we do not want them |
| 495 |
> |
* updating more frequently than once a second. |
| 496 |
> |
*/ |
| 497 |
> |
now = time(NULL); |
| 498 |
> |
if ((now - last_update) >= 1) { |
| 499 |
> |
get_stats(); |
| 500 |
> |
} |
| 501 |
> |
last_update = now; |
| 502 |
|
|
| 503 |
|
display_data(); |
| 496 |
– |
|
| 497 |
– |
/* To keep the numbers slightly accurate we do not want them updating more |
| 498 |
– |
* frequently than once a second. |
| 499 |
– |
*/ |
| 500 |
– |
sleep(1); |
| 504 |
|
} |
| 505 |
|
|
| 506 |
|
endwin(); |