CODE
while (1) { keycode = key_hook(); if (keycode == SPACE || keycode == BKSPACE) { render_again = 1; } if (keycode == ESC) break; if (render_again) { render_again = 0; render(all); } dprintf(1, ""); //I have no idea why this prevents the program from freezing } int key_hook() { char buffer[4]; read(0, buffer, 4); return (*(unsigned int *)buffer); }
Ok, so this piece of code handles redrawing text on the screen. Some lines of text are underlined or highlighted using termcaps (tputs(tgetstr("us, NULL")......) . Everything prints fine, but after the first redraw of the text, it seems to freeze if dprintf/printf present The key_hook function simply reads 4 bytes from stdin and converts them to int .
source share