Add kore.proc.pid, returns the PID of the proc.

This commit is contained in:
Joris Vink 2019-10-15 14:23:49 +02:00
parent ec249390b1
commit bc33a5def4
2 changed files with 14 additions and 0 deletions

View File

@ -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,

View File

@ -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)
{