summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2007-07-20 10:41:15 +0300
committerPanu Matilainen <pmatilai@redhat.com>2007-07-20 10:41:15 +0300
commit17b615eeb63e76bf0ee0f5fe26ff9401892b9265 (patch)
treef93c8dfb4e22a45f83642c1d12d87b6d06962927
parent3b3a700984c9f04e6dc5c9905b89d793d6ea5fda (diff)
downloadrpm-17b615eeb63e76bf0ee0f5fe26ff9401892b9265.tar.gz
rpm-17b615eeb63e76bf0ee0f5fe26ff9401892b9265.tar.bz2
rpm-17b615eeb63e76bf0ee0f5fe26ff9401892b9265.zip
Add python methods for checking pending signals from rpmsqCaught.
- a thin wrapper for rpmdbCheckSignals() from rpm5.org / Jeff Johnson - a function taking a list of signals to check and returning list caught signals (python doesn't know about signal sets so rpmsqCaught needs wrapping)
-rw-r--r--python/rpmmodule.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/python/rpmmodule.c b/python/rpmmodule.c
index 624dc2cf9..85b6db257 100644
--- a/python/rpmmodule.c
+++ b/python/rpmmodule.c
@@ -7,6 +7,7 @@
#include <rpmio_internal.h>
#include <rpmcli.h> /* XXX for rpmCheckSig */
#include <rpmdb.h>
+#include <rpmsq.h>
#include "legacy.h"
#include "misc.h"
@@ -58,6 +59,50 @@ static PyObject * archScore(PyObject * self, PyObject * args, PyObject * kwds)
}
/**
+ * */
+static PyObject * signalsCaught(PyObject * self, PyObject * check)
+{
+ PyObject *caught, *o;
+ Py_ssize_t llen;
+ int signum, i;
+ sigset_t newMask, oldMask;
+
+ if (!PyList_Check(check)) {
+ PyErr_SetString(PyExc_TypeError, "list expected");
+ return NULL;
+ }
+
+ llen = PyList_Size(check);
+ caught = PyList_New(0);
+
+ /* block signals while checking for them */
+ (void) sigfillset(&newMask);
+ (void) sigprocmask(SIG_BLOCK, &newMask, &oldMask);
+
+ for (i = 0; i < llen; i++) {
+ o = PyList_GetItem(check, i);
+ signum = PyInt_AsLong(o);
+ if (sigismember(&rpmsqCaught, signum)) {
+ PyList_Append(caught, o);
+ }
+ }
+ (void) sigprocmask(SIG_SETMASK, &oldMask, NULL);
+
+ return caught;
+}
+
+/**
+ * */
+static PyObject * checkSignals(PyObject * self, PyObject * args)
+{
+ if (!PyArg_ParseTuple(args, ":checkSignals")) return NULL;
+ rpmdbCheckSignals();
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+/**
*/
static PyObject * setLogFile (PyObject * self, PyObject * args, PyObject *kwds)
{
@@ -146,6 +191,11 @@ static PyMethodDef rpmModuleMethods[] = {
{ "archscore", (PyCFunction) archScore, METH_VARARGS|METH_KEYWORDS,
NULL },
+ { "signalsCaught", (PyCFunction) signalsCaught, METH_O,
+ NULL },
+ { "checkSignals", (PyCFunction) checkSignals, METH_VARARGS,
+ NULL },
+
{ "headerLoad", (PyCFunction) hdrLoad, METH_VARARGS|METH_KEYWORDS,
NULL },
{ "mergeHeaderListFromFD", (PyCFunction) rpmMergeHeadersFromFD, METH_VARARGS|METH_KEYWORDS,