Question

I wrote a signal handler that prints a line from buffer, it first removes the previous prompt, print a line and prints the prompt again at the end of the screen. here is my handler.

void print(int param)
{
  int c;
  signal(SIGALRM, print);
  printf("\b\b\b\b\b\b\b\b\b\b\033[0K");
  print_line();
  printf("\033[7m--HEY--\033[0m");
}

This handler is doing everything I wanted except that I could not see the prompt at the end of the screen. I do not understand why I am not able to see the prompt that?

Était-ce utile?

La solution

Standard output is usually line buffered. End with a \n character, or flush explicitly like this:

fflush(stdout);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top