diff options
author | Erik Troan <ewt@redhat.com> | 2000-11-08 16:41:27 +0000 |
---|---|---|
committer | Erik Troan <ewt@redhat.com> | 2000-11-08 16:41:27 +0000 |
commit | 6180555b3043d738e4225d7f0d2a7535b0c73e1e (patch) | |
tree | 9723e36f6dbbbbc9a65552a63f137cb3cab7094b /edd | |
parent | f20dbc0311a7869c710f07087b7d7c0fb9078e76 (diff) | |
download | anaconda-6180555b3043d738e4225d7f0d2a7535b0c73e1e.tar.gz anaconda-6180555b3043d738e4225d7f0d2a7535b0c73e1e.tar.xz anaconda-6180555b3043d738e4225d7f0d2a7535b0c73e1e.zip |
perform probe in a child process to work around seg faults
Diffstat (limited to 'edd')
-rw-r--r-- | edd/pyedd.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/edd/pyedd.c b/edd/pyedd.c index d98e4932d..8cd1f41c8 100644 --- a/edd/pyedd.c +++ b/edd/pyedd.c @@ -17,6 +17,9 @@ #include "edd.h" +#include <sys/wait.h> +#include <unistd.h> + #include <Python.h> static PyObject * edd_py_detect (PyObject * s, PyObject * args); @@ -30,14 +33,29 @@ static PyObject * edd_py_detect (PyObject * s, PyObject * args) { EDDCapability *ec; int device = 0x80; + pid_t childpid; + int status; if (!PyArg_ParseTuple(args, "|i", &device)) return NULL; - if ((ec = edd_supported(device))) { - free (ec); - return Py_BuildValue ("i", 1); + /* Run this probe as a child as it sometimes segv's in the vm stuff. + The child returns 1 if edd works, and 0 if it doesn't. */ + + if (!(childpid = fork())) { + if ((ec = edd_supported(device))) { + free (ec); + exit(1); + } + + exit(0); } + + waitpid(childpid, &status, 0); + + if (WIFEXITED(status) && WEXITSTATUS(status)) + return Py_BuildValue ("i", 1); + return Py_BuildValue ("i", 0); } |