/** Catches thrown signals. Performs necessary cleanup to ensure database is * in a consistent state. * @param signum the thrown signal */ static void soft_interrupt_handler(int signum) { #ifdef __MSYS__ struct termios term; #endif if(signum == SIGINT) { const char msg[] = "\nInterrupt signal received\n"; xwrite(STDERR_FILENO, msg, ARRAYSIZE(msg) - 1); } else { const char msg[] = "\nHangup signal received\n"; xwrite(STDERR_FILENO, msg, ARRAYSIZE(msg) - 1); } if(alpm_trans_interrupt(config->handle) == 0) { /* a transaction is being interrupted, don't exit pacman yet. */ return; } alpm_unlock(config->handle); #ifdef __MSYS__ /* restore input printing possibly disabled by core update */ if(tcgetattr(STDIN_FILENO, &term) == 0) { term.c_lflag |= ECHO; tcsetattr(STDIN_FILENO, TCSAFLUSH, &term); } #endif /* output a newline to be sure we clear any line we may be on */ xwrite(STDOUT_FILENO, "\n", 1); _Exit(128 + signum); }
/** Catches thrown signals. Performs necessary cleanup to ensure database is * in a consistent state. * @param signum the thrown signal */ static void soft_interrupt_handler(int signum) { if(signum == SIGINT) { const char msg[] = "\nInterrupt signal received\n"; xwrite(STDERR_FILENO, msg, ARRAYSIZE(msg) - 1); } else { const char msg[] = "\nHangup signal received\n"; xwrite(STDERR_FILENO, msg, ARRAYSIZE(msg) - 1); } if(alpm_trans_interrupt(config->handle) == 0) { /* a transaction is being interrupted, don't exit pacman yet. */ return; } alpm_unlock(config->handle); /* output a newline to be sure we clear any line we may be on */ xwrite(STDOUT_FILENO, "\n", 1); _Exit(128 + signum); }