diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index ea536a47..e5c6e420 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -289,6 +289,7 @@ static void setuseragent(void) */ static void cleanup(int ret) { + console_cursor_show(); remove_soft_interrupt_handler(); if(config) { /* free alpm library resources */ @@ -302,7 +303,6 @@ static void cleanup(int ret) /* free memory */ FREELIST(pm_targets); - console_cursor_show(); exit(ret); } diff --git a/src/pacman/util.c b/src/pacman/util.c index 53833d6f..d57867ab 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -1427,6 +1427,15 @@ void console_cursor_show(void) { if(isatty(fileno(stdout))) { printf(CURSOR_SHOW_ANSICODE); } + + /* We typically explicitly show the cursor either when we are getting + * input from stdin, or when we are in the process of exiting. In the + * former case, it's not guaranteed that the terminal will see the + * command before reading from stdin. In the latter case, we need to + * make sure that if we get a further TERM/INT after we return signal + * disposition to SIG_DFL, it doesn't leave the cursor invisible. + */ + fflush(stdout); } char *safe_fgets_stdin(char *s, int size)