View | Details | Raw Unified | Return to bug 30939
Collapse All | Expand All

(-)contrib/top/top.c (-2 / +15 lines)
Lines 157-162 Link Here
157
    int topn = Default_TOPN;
157
    int topn = Default_TOPN;
158
    int delay = Default_DELAY;
158
    int delay = Default_DELAY;
159
    int displays = 0;		/* indicates unspecified */
159
    int displays = 0;		/* indicates unspecified */
160
    int sel_ret = 0;
160
    time_t curr_time;
161
    time_t curr_time;
161
    char *(*get_userid)() = username;
162
    char *(*get_userid)() = username;
162
    char *uname_field = "USERNAME";
163
    char *uname_field = "USERNAME";
Lines 711-717 Link Here
711
		}
712
		}
712
713
713
		/* wait for either input or the end of the delay period */
714
		/* wait for either input or the end of the delay period */
714
		if (select(32, &readfds, (fd_set *)NULL, (fd_set *)NULL, &timeout) > 0)
715
		sel_ret = select(2, &readfds, (fd_set *)NULL, (fd_set *)NULL,
716
				 &timeout);
717
		if (sel_ret > 0)
715
		{
718
		{
716
		    int newval;
719
		    int newval;
717
		    char *errmsg;
720
		    char *errmsg;
Lines 721-727 Link Here
721
724
722
		    /* now read it and convert to command strchr */
725
		    /* now read it and convert to command strchr */
723
		    /* (use "change" as a temporary to hold strchr) */
726
		    /* (use "change" as a temporary to hold strchr) */
724
		    (void) read(0, &ch, 1);
727
		    /* sleep if input from stdin causes error */
728
		    if (read(0, &ch, 1) != 1)
729
		    {
730
			ch = '\r';
731
			sleep(delay);
732
		    }
725
		    if ((iptr = strchr(command_chars, ch)) == NULL)
733
		    if ((iptr = strchr(command_chars, ch)) == NULL)
726
		    {
734
		    {
727
			if (ch != '\r' && ch != '\n')
735
			if (ch != '\r' && ch != '\n')
Lines 960-965 Link Here
960
968
961
		    /* flush out stuff that may have been written */
969
		    /* flush out stuff that may have been written */
962
		    fflush(stdout);
970
		    fflush(stdout);
971
		}
972
		/* sleep if input from stdin causes error */
973
		if (sel_ret < 0)
974
		{
975
		    sleep(delay);
963
		}
976
		}
964
	    }
977
	    }
965
	}
978
	}

Return to bug 30939