]> git.ipfire.org Git - pakfire.git/commitdiff
python: execute: Raise OS error when starting the process failed
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 21 Jan 2021 11:19:08 +0000 (11:19 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 21 Jan 2021 11:19:08 +0000 (11:19 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/pakfire.c

index e5fae08efaeed20c686c9da47ee7acabcd178737..6cf25d00d795bd2f9ba3e5948cec263bbd9acefe 100644 (file)
@@ -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);