430 |
|
|
431 |
|
WINDOW *window; |
432 |
|
|
433 |
– |
int stdin_fileno; |
434 |
– |
fd_set infds; |
435 |
– |
struct timeval timeout; |
436 |
– |
|
433 |
|
extern int errno; |
438 |
– |
char ch; |
434 |
|
|
435 |
|
int delay=2; |
436 |
|
#ifdef ALLBSD |
444 |
|
} |
445 |
|
#endif |
446 |
|
|
447 |
< |
while ((c = getopt(argc, argv, "vhd:")) != EOF){ |
447 |
> |
while ((c = getopt(argc, argv, "vhd:")) != -1){ |
448 |
|
switch (c){ |
449 |
|
case 'd': |
450 |
|
delay = atoi(optarg); |
471 |
|
nonl(); |
472 |
|
cbreak(); |
473 |
|
noecho(); |
474 |
+ |
timeout(delay * 1000); |
475 |
|
window=newwin(0, 0, 0, 0); |
476 |
|
clear(); |
477 |
|
|
482 |
|
} |
483 |
|
|
484 |
|
display_headings(); |
489 |
– |
stdin_fileno=fileno(stdin); |
485 |
|
|
486 |
|
for(;;){ |
487 |
< |
|
488 |
< |
FD_ZERO(&infds); |
489 |
< |
FD_SET(stdin_fileno, &infds); |
490 |
< |
timeout.tv_sec = delay; |
496 |
< |
timeout.tv_usec = 0; |
497 |
< |
|
498 |
< |
if((select((stdin_fileno+1), &infds, NULL, NULL, &timeout)) == -1){ |
499 |
< |
if(errno!=EINTR){ |
500 |
< |
perror("select failed"); |
501 |
< |
exit(1); |
502 |
< |
} |
503 |
< |
} |
504 |
< |
|
505 |
< |
if(FD_ISSET(stdin_fileno, &infds)){ |
506 |
< |
ch=getch(); |
507 |
< |
if (ch == 'q'){ |
508 |
< |
endwin(); |
509 |
< |
return 0; |
510 |
< |
} |
487 |
> |
int ch = getch(); |
488 |
> |
if (ch == 'q'){ |
489 |
> |
endwin(); |
490 |
> |
return 0; |
491 |
|
} |
492 |
|
|
493 |
|
get_stats(); |