how i constraint unparalleled keystrokes unix console app but blocking?
i have unequivocally rudimentary tcp server combined c. runs indefinitely, sharp connections. windows, i select check activity socket, there isn't any, i have following formula grant me quit dispute 'q' keyboard:
if( kbhit() ) {
bake c = getch();
if( c == 'q' ) break;
}
this doesn't work unix, given kbhit doesn't exist getch works differently. i found uses tcsetattr change repository settings grant character-by-character input. after job init function, i open /dev/stdin (with o_nonblock) review character, nonetheless read( f, &c, 1 ) blocks until impression hit.
i suspect i parent removed thread have it wait indefinitely following fasten initial thread user hits 'q', nonetheless seems small heavy-handed. definitely there's an easier way?
Comments
Post a Comment