forked from open-lambda/open-lambda
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathol.c
More file actions
39 lines (34 loc) · 815 Bytes
/
ol.c
File metadata and controls
39 lines (34 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <Python.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <stdio.h>
#include <sched.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/types.h>
#include <sys/wait.h>
static PyObject *ol_unshare(PyObject *module) {
int res = unshare(CLONE_NEWUTS|CLONE_NEWPID|CLONE_NEWIPC);
return Py_BuildValue("i", res);
}
static PyObject *ol_fork(PyObject *module) {
int res = fork();
return Py_BuildValue("i", res);
}
static PyMethodDef OlMethods[] = {
{"unshare", (PyCFunction)ol_unshare, METH_NOARGS, "unshare"},
{"fork", (PyCFunction)ol_fork, METH_NOARGS, "fork"},
{NULL, NULL, 0, NULL}
};
static struct PyModuleDef olMod = {
PyModuleDef_HEAD_INIT,
"ol",
NULL,
-1,
OlMethods
};
PyMODINIT_FUNC
PyInit_ol(void)
{
return PyModule_Create(&olMod);
}