428 |
|
extern int optind; |
429 |
|
int c; |
430 |
|
|
431 |
+ |
time_t last_update = 0; |
432 |
+ |
|
433 |
|
WINDOW *window; |
434 |
|
|
435 |
|
extern int errno; |
434 |
– |
char ch; |
436 |
|
|
437 |
|
int delay=2; |
438 |
< |
#ifdef ALLBSD |
438 |
< |
gid_t gid; |
439 |
< |
#endif |
438 |
> |
|
439 |
|
statgrab_init(); |
440 |
|
#ifdef ALLBSD |
441 |
|
if((setegid(getgid())) != 0){ |
443 |
|
return 1; |
444 |
|
} |
445 |
|
#endif |
446 |
+ |
#ifdef SOLARIS |
447 |
+ |
if((seteuid(getuid())) != 0){ |
448 |
+ |
fprintf(stderr, "Failed to lose setuid'ness\n"); |
449 |
+ |
return 1; |
450 |
+ |
} |
451 |
+ |
#endif |
452 |
|
|
453 |
< |
while ((c = getopt(argc, argv, "vhd:")) != EOF){ |
453 |
> |
while ((c = getopt(argc, argv, "vhd:")) != -1){ |
454 |
|
switch (c){ |
455 |
|
case 'd': |
456 |
|
delay = atoi(optarg); |
458 |
|
fprintf(stderr, "Time must be 1 second or greater\n"); |
459 |
|
exit(1); |
460 |
|
} |
456 |
– |
delay--; |
461 |
|
break; |
462 |
|
case 'v': |
463 |
|
version_num(argv[0]); |
467 |
|
usage(argv[0]); |
468 |
|
return 1; |
469 |
|
break; |
466 |
– |
|
470 |
|
} |
471 |
|
} |
472 |
|
|
488 |
|
display_headings(); |
489 |
|
|
490 |
|
for(;;){ |
491 |
< |
ch = getch(); |
491 |
> |
time_t now; |
492 |
> |
int ch = getch(); |
493 |
> |
|
494 |
|
if (ch == 'q'){ |
495 |
< |
endwin(); |
491 |
< |
return 0; |
495 |
> |
break; |
496 |
|
} |
497 |
|
|
498 |
< |
get_stats(); |
498 |
> |
/* To keep the numbers slightly accurate we do not want them |
499 |
> |
* updating more frequently than once a second. |
500 |
> |
*/ |
501 |
> |
now = time(NULL); |
502 |
> |
if ((now - last_update) >= 1) { |
503 |
> |
get_stats(); |
504 |
> |
} |
505 |
> |
last_update = now; |
506 |
|
|
507 |
|
display_data(); |
497 |
– |
|
498 |
– |
/* To keep the numbers slightly accurate we do not want them updating more |
499 |
– |
* frequently than once a second. |
500 |
– |
*/ |
501 |
– |
sleep(1); |
508 |
|
} |
509 |
|
|
510 |
|
endwin(); |