From: Michael Tremer Date: Thu, 21 Jan 2021 11:19:08 +0000 (+0000) Subject: python: execute: Raise OS error when starting the process failed X-Git-Tag: 0.9.28~1285^2~830 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d16c080510f5f91e1d0769b613f9308372c481a;p=pakfire.git python: execute: Raise OS error when starting the process failed Signed-off-by: Michael Tremer --- diff --git a/src/_pakfire/pakfire.c b/src/_pakfire/pakfire.c index e5fae08ef..6cf25d00d 100644 --- a/src/_pakfire/pakfire.c +++ b/src/_pakfire/pakfire.c @@ -497,8 +497,15 @@ static PyObject* Pakfire_execute(PakfireObject* self, PyObject* args, PyObject* for (unsigned int i = 0; envp[i]; i++) free(envp[i]); + // Raise an OS error if r < 0 + if (r < 0) { + errno = -r; + + PyErr_SetFromErrno(PyExc_OSError); + return NULL; + // Raise exception when the command failed - if (r) { + } else if (r > 0) { PyObject* code = PyLong_FromLong(r); PyErr_SetObject(PyExc_CommandExecutionError, code);