I\'ve got code similar to the following, using readline:
#include
#include
#include
#include
Creating a jump seems hacky and error-prone to me. The shell implementation I was adding this support to didn't allow for this change.
Luckily, readlinehas a clearer, alternative solution. My SIGINT handler looks like this:
static void
int_handler(int status) {
printf("\n"); // Move to a new line
rl_on_new_line(); // Regenerate the prompt on a newline
rl_replace_line("", 0); // Clear the previous text
rl_redisplay();
}
This took no other additional code elsewhere to get this working — no global variables, no setting jumps.