diff --git a/include/kore/python_methods.h b/include/kore/python_methods.h index 48acfdb..dadf1e8 100644 --- a/include/kore/python_methods.h +++ b/include/kore/python_methods.h @@ -539,10 +539,18 @@ static PyMethodDef pyproc_methods[] = { METHOD(NULL, NULL, -1), }; +static PyObject *pyproc_get_pid(struct pyproc *, void *); + +static PyGetSetDef pyproc_getset[] = { + GETTER("pid", pyproc_get_pid), + GETTER(NULL, NULL), +}; + static PyTypeObject pyproc_type = { PyVarObject_HEAD_INIT(NULL, 0) .tp_name = "kore.proc", .tp_doc = "async process", + .tp_getset = pyproc_getset, .tp_methods = pyproc_methods, .tp_basicsize = sizeof(struct pyproc), .tp_dealloc = (destructor)pyproc_dealloc, diff --git a/src/python.c b/src/python.c index 712804e..1e156e0 100644 --- a/src/python.c +++ b/src/python.c @@ -3690,6 +3690,12 @@ pyproc_close_stdin(struct pyproc *proc, PyObject *args) Py_RETURN_TRUE; } +static PyObject * +pyproc_get_pid(struct pyproc *proc, void *closure) +{ + return (PyLong_FromLong(proc->pid)); +} + static void pyproc_op_dealloc(struct pyproc_op *op) {