Ejemplo n.º 1
0
/** Catches thrown signals. Performs necessary cleanup to ensure database is
 * in a consistent state.
 * @param signum the thrown signal
 */
static void handler(int signum)
{
	int out = fileno(stdout);
	int err = fileno(stderr);
	const char *msg;
	if(signum == SIGSEGV) {
		msg = "\nerror: segmentation fault\n"
			"Please submit a full bug report with --debug if appropriate.\n";
		xwrite(err, msg, strlen(msg));
		exit(signum);
	} else if(signum == SIGINT || signum == SIGHUP) {
		if(signum == SIGINT) {
			msg = "\nInterrupt signal received\n";
		} else {
			msg = "\nHangup signal received\n";
		}
		xwrite(err, msg, strlen(msg));
		if(alpm_trans_interrupt(config->handle) == 0) {
			/* a transaction is being interrupted, don't exit pacman yet. */
			return;
		}
	} else if(signum == SIGWINCH) {
		columns_cache_reset();
		return;
	}
	/* SIGINT/SIGHUP: no committing transaction, release it now and then exit pacman
	 * SIGTERM: release no matter what */
	alpm_trans_release(config->handle);
	/* output a newline to be sure we clear any line we may be on */
	xwrite(out, "\n", 1);
	cleanup(128 + signum);
}
Ejemplo n.º 2
0
static void winch_handler(int signum)
{
	(void)signum; /* suppress unused variable warnings */
	columns_cache_reset();
}