| 428 |
|
extern int optind; |
| 429 |
|
int c; |
| 430 |
|
|
| 431 |
+ |
time_t last_update = 0; |
| 432 |
+ |
|
| 433 |
|
WINDOW *window; |
| 434 |
|
|
| 435 |
|
extern int errno; |
| 445 |
|
return 1; |
| 446 |
|
} |
| 447 |
|
#endif |
| 448 |
+ |
#ifdef SOLARIS |
| 449 |
+ |
if((seteuid(getuid())) != 0){ |
| 450 |
+ |
fprintf(stderr, "Failed to lose setuid'ness\n"); |
| 451 |
+ |
return 1; |
| 452 |
+ |
} |
| 453 |
+ |
#endif |
| 454 |
|
|
| 455 |
|
while ((c = getopt(argc, argv, "vhd:")) != -1){ |
| 456 |
|
switch (c){ |
| 460 |
|
fprintf(stderr, "Time must be 1 second or greater\n"); |
| 461 |
|
exit(1); |
| 462 |
|
} |
| 455 |
– |
delay--; |
| 463 |
|
break; |
| 464 |
|
case 'v': |
| 465 |
|
version_num(argv[0]); |
| 469 |
|
usage(argv[0]); |
| 470 |
|
return 1; |
| 471 |
|
break; |
| 465 |
– |
|
| 472 |
|
} |
| 473 |
|
} |
| 474 |
|
|
| 490 |
|
display_headings(); |
| 491 |
|
|
| 492 |
|
for(;;){ |
| 493 |
+ |
time_t now; |
| 494 |
|
int ch = getch(); |
| 495 |
+ |
|
| 496 |
|
if (ch == 'q'){ |
| 497 |
< |
endwin(); |
| 490 |
< |
return 0; |
| 497 |
> |
break; |
| 498 |
|
} |
| 499 |
|
|
| 500 |
< |
get_stats(); |
| 500 |
> |
/* To keep the numbers slightly accurate we do not want them |
| 501 |
> |
* updating more frequently than once a second. |
| 502 |
> |
*/ |
| 503 |
> |
now = time(NULL); |
| 504 |
> |
if ((now - last_update) >= 1) { |
| 505 |
> |
get_stats(); |
| 506 |
> |
} |
| 507 |
> |
last_update = now; |
| 508 |
|
|
| 509 |
|
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); |
| 510 |
|
} |
| 511 |
|
|
| 512 |
|
endwin(); |