Exemplo n.º 1
0
/** 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);
}
Exemplo n.º 2
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);
}
Exemplo n.º 3
0
/* int alpm_trans_interrupt(void); */
int lalpm_trans_interrupt(lua_State *L)
{
    const int result = alpm_trans_interrupt();
    lua_pushnumber(L, result);

    return 1;
}
static void
transaction_cancelled_cb (GCancellable *object, gpointer data)
{
	g_return_if_fail (data != NULL);
	g_return_if_fail (alpm != NULL);

	alpm_trans_interrupt (alpm);
}
Exemplo n.º 5
0
/**
 * pacman_transaction_cancel:
 * @transaction: A #PacmanTransaction.
 * @error: A #GError, or %NULL.
 *
 * Cancels the commit operation of @transaction.
 *
 * Returns: %TRUE if @transaction could be cancelled, or %FALSE if @error is set.
 */
gboolean pacman_transaction_cancel (PacmanTransaction *transaction, GError **error) {
	g_return_val_if_fail (transaction != NULL, FALSE);
	
	if (alpm_trans_interrupt () < 0) {
		g_set_error (error, PACMAN_ERROR, pm_errno, _("Could not cancel transaction: %s"), alpm_strerrorlast ());
		return FALSE;
	}
	
	return TRUE;
}
Exemplo n.º 6
0
/** 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);
}
Exemplo n.º 7
0
static PyObject* pyalpm_trans_interrupt(PyObject *self, PyObject *args) {
  alpm_handle_t *handle = ALPM_HANDLE(self);
  int ret = alpm_trans_interrupt(handle);
  if (ret == -1) RET_ERR("unable to interrupt transaction", alpm_errno(handle), NULL);
  Py_RETURN_NONE;
}