Linux vps-61133.fhnet.fr 4.9.0-19-amd64 #1 SMP Debian 4.9.320-2 (2022-06-30) x86_64
Apache/2.4.25 (Debian)
Server IP : 93.113.207.21 & Your IP : 216.73.216.35
Domains :
Cant Read [ /etc/named.conf ]
User : www-data
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
usr /
src /
Python-3.10.14 /
Modules /
Delete
Unzip
Name
Size
Permission
Date
Action
_blake2
[ DIR ]
drwxr-xr-x
2024-03-19 22:46
_ctypes
[ DIR ]
drwxr-xr-x
2024-03-19 22:46
_decimal
[ DIR ]
drwxr-xr-x
2024-03-19 22:46
_io
[ DIR ]
drwxr-xr-x
2024-03-19 22:46
_multiprocessing
[ DIR ]
drwxr-xr-x
2024-03-19 22:46
_sha3
[ DIR ]
drwxr-xr-x
2024-03-19 22:46
_sqlite
[ DIR ]
drwxr-xr-x
2024-03-19 22:46
_ssl
[ DIR ]
drwxr-xr-x
2024-03-19 22:46
_xxtestfuzz
[ DIR ]
drwxr-xr-x
2024-03-19 22:46
cjkcodecs
[ DIR ]
drwxr-xr-x
2024-03-19 22:46
clinic
[ DIR ]
drwxr-xr-x
2024-03-19 22:46
expat
[ DIR ]
drwxr-xr-x
2024-03-19 22:46
README
112
B
-rw-r--r--
2024-03-19 22:46
Setup
15.15
KB
-rw-r--r--
2024-03-19 22:46
Setup.local
41
B
-rw-r--r--
2025-06-04 09:17
_abc.c
26.09
KB
-rw-r--r--
2024-03-19 22:46
_abc.gcda
8.21
KB
-rw-r--r--
2025-06-04 09:21
_abc.o
228.27
KB
-rw-r--r--
2025-06-04 09:22
_asynciomodule.c
88.39
KB
-rw-r--r--
2024-03-19 22:46
_bisectmodule.c
8.03
KB
-rw-r--r--
2024-03-19 22:46
_bz2module.c
23.65
KB
-rw-r--r--
2024-03-19 22:46
_codecsmodule.c
32.8
KB
-rw-r--r--
2024-03-19 22:46
_codecsmodule.gcda
13.72
KB
-rw-r--r--
2025-06-04 09:21
_codecsmodule.o
374.94
KB
-rw-r--r--
2025-06-04 09:22
_collectionsmodule.c
79.83
KB
-rw-r--r--
2024-03-19 22:46
_collectionsmodule.gcda
14.42
KB
-rw-r--r--
2025-06-04 09:21
_collectionsmodule.o
325.15
KB
-rw-r--r--
2025-06-04 09:22
_contextvarsmodule.c
1.57
KB
-rw-r--r--
2024-03-19 22:46
_cryptmodule.c
1.66
KB
-rw-r--r--
2024-03-19 22:46
_csv.c
50.09
KB
-rw-r--r--
2024-03-19 22:46
_curses_panel.c
18.6
KB
-rw-r--r--
2024-03-19 22:46
_cursesmodule.c
135.6
KB
-rw-r--r--
2024-03-19 22:46
_datetimemodule.c
219.13
KB
-rw-r--r--
2024-03-19 22:46
_dbmmodule.c
14.9
KB
-rw-r--r--
2024-03-19 22:46
_elementtree.c
124.95
KB
-rw-r--r--
2024-03-19 22:46
_functoolsmodule.c
45.07
KB
-rw-r--r--
2024-03-19 22:46
_functoolsmodule.gcda
11.74
KB
-rw-r--r--
2025-06-04 09:21
_functoolsmodule.o
268.69
KB
-rw-r--r--
2025-06-04 09:22
_gdbmmodule.c
21.25
KB
-rw-r--r--
2024-03-19 22:46
_hashopenssl.c
59.7
KB
-rw-r--r--
2024-03-19 22:46
_heapqmodule.c
21.78
KB
-rw-r--r--
2024-03-19 22:46
_iomodule.gcda
6.99
KB
-rw-r--r--
2025-06-04 09:21
_iomodule.o
186.38
KB
-rw-r--r--
2025-06-04 09:22
_json.c
57.57
KB
-rw-r--r--
2024-03-19 22:46
_localemodule.c
22.29
KB
-rw-r--r--
2024-03-19 22:46
_localemodule.gcda
8.57
KB
-rw-r--r--
2025-06-04 09:21
_localemodule.o
181.06
KB
-rw-r--r--
2025-06-04 09:22
_lsprof.c
25.89
KB
-rw-r--r--
2024-03-19 22:46
_lzmamodule.c
48.65
KB
-rw-r--r--
2024-03-19 22:46
_math.c
7.33
KB
-rw-r--r--
2024-03-19 22:46
_math.gcda
2.29
KB
-rw-r--r--
2025-06-04 09:21
_math.h
1007
B
-rw-r--r--
2024-03-19 22:46
_math.o
32.3
KB
-rw-r--r--
2025-06-04 09:22
_opcode.c
2.14
KB
-rw-r--r--
2024-03-19 22:46
_operator.c
46.15
KB
-rw-r--r--
2024-03-19 22:46
_operator.gcda
13.14
KB
-rw-r--r--
2025-06-04 09:21
_operator.o
333.74
KB
-rw-r--r--
2025-06-04 09:22
_pickle.c
229.53
KB
-rw-r--r--
2024-03-19 22:46
_posixsubprocess.c
36.98
KB
-rw-r--r--
2024-03-19 22:46
_queuemodule.c
12.31
KB
-rw-r--r--
2024-03-19 22:46
_randommodule.c
17.76
KB
-rw-r--r--
2024-03-19 22:46
_scproxy.c
6.08
KB
-rw-r--r--
2024-03-19 22:46
_sre.c
79.74
KB
-rw-r--r--
2024-03-19 22:46
_sre.gcda
34.64
KB
-rw-r--r--
2025-06-04 09:21
_sre.o
975.16
KB
-rw-r--r--
2025-06-04 09:22
_ssl.c
186.63
KB
-rw-r--r--
2024-03-19 22:46
_ssl.h
2.08
KB
-rw-r--r--
2024-03-19 22:46
_ssl_data.h
203.14
KB
-rw-r--r--
2024-03-19 22:46
_ssl_data_111.h
208.74
KB
-rw-r--r--
2024-03-19 22:46
_ssl_data_300.h
275.25
KB
-rw-r--r--
2024-03-19 22:46
_stat.c
15.18
KB
-rw-r--r--
2024-03-19 22:46
_stat.gcda
5.7
KB
-rw-r--r--
2025-06-04 09:21
_stat.o
69.77
KB
-rw-r--r--
2025-06-04 09:22
_statisticsmodule.c
4.83
KB
-rw-r--r--
2024-03-19 22:46
_struct.c
68.85
KB
-rw-r--r--
2024-03-19 22:46
_testbuffer.c
82.19
KB
-rw-r--r--
2024-03-19 22:46
_testcapimodule.c
217.47
KB
-rw-r--r--
2024-03-19 22:46
_testclinic.c
22.92
KB
-rw-r--r--
2024-03-19 22:46
_testimportmultiple.c
1.1
KB
-rw-r--r--
2024-03-19 22:46
_testinternalcapi.c
10.76
KB
-rw-r--r--
2024-03-19 22:46
_testmultiphase.c
23.38
KB
-rw-r--r--
2024-03-19 22:46
_threadmodule.c
50.27
KB
-rw-r--r--
2024-03-19 22:46
_threadmodule.gcda
10.46
KB
-rw-r--r--
2025-06-04 09:21
_threadmodule.o
250.8
KB
-rw-r--r--
2025-06-04 09:22
_tkinter.c
93.36
KB
-rw-r--r--
2024-03-19 22:46
_tracemalloc.c
44.86
KB
-rw-r--r--
2024-03-19 22:46
_tracemalloc.gcda
12.51
KB
-rw-r--r--
2025-06-04 09:21
_tracemalloc.o
262.77
KB
-rw-r--r--
2025-06-04 09:22
_uuidmodule.c
3
KB
-rw-r--r--
2024-03-19 22:46
_weakref.c
4.92
KB
-rw-r--r--
2024-03-19 22:46
_weakref.gcda
4.24
KB
-rw-r--r--
2025-06-04 09:21
_weakref.o
84.91
KB
-rw-r--r--
2025-06-04 09:22
_winapi.c
66.78
KB
-rw-r--r--
2024-03-19 22:46
_xxsubinterpretersmodule.c
67.74
KB
-rw-r--r--
2024-03-19 22:46
_zoneinfo.c
73.89
KB
-rw-r--r--
2024-03-19 22:46
addrinfo.h
5.88
KB
-rw-r--r--
2024-03-19 22:46
arraymodule.c
87.46
KB
-rw-r--r--
2024-03-19 22:46
atexitmodule.c
7.29
KB
-rw-r--r--
2024-03-19 22:46
atexitmodule.gcda
4.45
KB
-rw-r--r--
2025-06-04 09:21
atexitmodule.o
97.11
KB
-rw-r--r--
2025-06-04 09:22
audioop.c
59.71
KB
-rw-r--r--
2024-03-19 22:46
binascii.c
54.76
KB
-rw-r--r--
2024-03-19 22:46
bufferedio.gcda
20.46
KB
-rw-r--r--
2025-06-04 09:21
bufferedio.o
414.2
KB
-rw-r--r--
2025-06-04 09:22
bytesio.gcda
10.84
KB
-rw-r--r--
2025-06-04 09:21
bytesio.o
220.71
KB
-rw-r--r--
2025-06-04 09:22
cmathmodule.c
42.3
KB
-rw-r--r--
2024-03-19 22:46
config.c
3.21
KB
-rw-r--r--
2025-06-04 09:17
config.c.in
1.58
KB
-rw-r--r--
2024-03-19 22:46
config.o
34.5
KB
-rw-r--r--
2025-06-04 09:22
errnomodule.c
27.08
KB
-rw-r--r--
2024-03-19 22:46
errnomodule.gcda
8.02
KB
-rw-r--r--
2025-06-04 09:21
errnomodule.o
113.31
KB
-rw-r--r--
2025-06-04 09:22
faulthandler.c
40.52
KB
-rw-r--r--
2024-03-19 22:46
faulthandler.gcda
9.1
KB
-rw-r--r--
2025-06-04 09:21
faulthandler.o
147.28
KB
-rw-r--r--
2025-06-04 09:22
fcntlmodule.c
20.49
KB
-rw-r--r--
2024-03-19 22:46
fileio.gcda
9.01
KB
-rw-r--r--
2025-06-04 09:21
fileio.o
227.98
KB
-rw-r--r--
2025-06-04 09:22
gc_weakref.txt
11.19
KB
-rw-r--r--
2024-03-19 22:46
gcmodule.c
77.27
KB
-rw-r--r--
2024-03-19 22:46
gcmodule.gcda
11.63
KB
-rw-r--r--
2025-06-04 09:21
gcmodule.o
306.44
KB
-rw-r--r--
2025-06-04 09:22
getaddrinfo.c
18.38
KB
-rw-r--r--
2024-03-19 22:46
getbuildinfo.c
1.28
KB
-rw-r--r--
2024-03-19 22:46
getbuildinfo.gcda
3.59
KB
-rw-r--r--
2025-06-04 09:21
getbuildinfo.o
33.84
KB
-rw-r--r--
2025-06-04 09:22
getnameinfo.c
6.18
KB
-rw-r--r--
2024-03-19 22:46
getpath.c
44.99
KB
-rw-r--r--
2024-03-19 22:46
getpath.gcda
8.82
KB
-rw-r--r--
2025-06-04 09:21
getpath.o
160.52
KB
-rw-r--r--
2025-06-04 09:22
grpmodule.c
8.52
KB
-rw-r--r--
2024-03-19 22:46
hashlib.h
2.09
KB
-rw-r--r--
2024-03-19 22:46
iobase.gcda
9.63
KB
-rw-r--r--
2025-06-04 09:21
iobase.o
189.36
KB
-rw-r--r--
2025-06-04 09:22
itertoolsmodule.c
153.67
KB
-rw-r--r--
2024-03-19 22:46
itertoolsmodule.gcda
27.9
KB
-rw-r--r--
2025-06-04 09:21
itertoolsmodule.o
721.27
KB
-rw-r--r--
2025-06-04 09:22
ld_so_aix
6.12
KB
-rwxr-xr-x
2025-06-04 09:17
ld_so_aix.in
6.11
KB
-rw-r--r--
2024-03-19 22:46
main.c
17.65
KB
-rw-r--r--
2024-03-19 22:46
main.gcda
7.28
KB
-rw-r--r--
2025-06-04 09:21
main.o
147.24
KB
-rw-r--r--
2025-06-04 09:22
makesetup
7.67
KB
-rwxr-xr-x
2024-03-19 22:46
makexp_aix
2.67
KB
-rwxr-xr-x
2024-03-19 22:46
mathmodule.c
106.2
KB
-rw-r--r--
2024-03-19 22:46
md5module.c
15.51
KB
-rw-r--r--
2024-03-19 22:46
mmapmodule.c
47.75
KB
-rw-r--r--
2024-03-19 22:46
nismodule.c
12.89
KB
-rw-r--r--
2024-03-19 22:46
ossaudiodev.c
37.49
KB
-rw-r--r--
2024-03-19 22:46
overlapped.c
53.65
KB
-rw-r--r--
2024-03-19 22:46
posixmodule.c
413.46
KB
-rw-r--r--
2024-03-19 22:46
posixmodule.gcda
67.8
KB
-rw-r--r--
2025-06-04 09:21
posixmodule.h
791
B
-rw-r--r--
2024-03-19 22:46
posixmodule.o
1.49
MB
-rw-r--r--
2025-06-04 09:22
pwdmodule.c
8.89
KB
-rw-r--r--
2024-03-19 22:46
pwdmodule.gcda
4.96
KB
-rw-r--r--
2025-06-04 09:21
pwdmodule.o
84.35
KB
-rw-r--r--
2025-06-04 09:22
pyexpat.c
60.39
KB
-rw-r--r--
2024-03-19 22:46
readline.c
40.06
KB
-rw-r--r--
2024-03-19 22:46
resource.c
13.77
KB
-rw-r--r--
2024-03-19 22:46
rotatingtree.c
3.39
KB
-rw-r--r--
2024-03-19 22:46
rotatingtree.h
924
B
-rw-r--r--
2024-03-19 22:46
selectmodule.c
70.06
KB
-rw-r--r--
2024-03-19 22:46
sha1module.c
14.76
KB
-rw-r--r--
2024-03-19 22:46
sha256module.c
22.5
KB
-rw-r--r--
2024-03-19 22:46
sha512module.c
27.29
KB
-rw-r--r--
2024-03-19 22:46
signalmodule.c
52.45
KB
-rw-r--r--
2024-03-19 22:46
signalmodule.gcda
11.11
KB
-rw-r--r--
2025-06-04 09:21
signalmodule.o
235.02
KB
-rw-r--r--
2025-06-04 09:22
socketmodule.c
243.34
KB
-rw-r--r--
2024-03-19 22:46
socketmodule.h
8.56
KB
-rw-r--r--
2024-03-19 22:46
spwdmodule.c
6.69
KB
-rw-r--r--
2024-03-19 22:46
sre.h
2.83
KB
-rw-r--r--
2024-03-19 22:46
sre_constants.h
2.81
KB
-rw-r--r--
2024-03-19 22:46
sre_lib.h
52.08
KB
-rw-r--r--
2024-03-19 22:46
stringio.gcda
9.64
KB
-rw-r--r--
2025-06-04 09:21
stringio.o
193.45
KB
-rw-r--r--
2025-06-04 09:22
symtablemodule.c
3.67
KB
-rw-r--r--
2024-03-19 22:46
symtablemodule.gcda
4.25
KB
-rw-r--r--
2025-06-04 09:21
symtablemodule.o
55.01
KB
-rw-r--r--
2025-06-04 09:22
syslogmodule.c
10.64
KB
-rw-r--r--
2024-03-19 22:46
termios.c
22.52
KB
-rw-r--r--
2024-03-19 22:46
testcapi_long.h
6.77
KB
-rw-r--r--
2024-03-19 22:46
textio.gcda
23.51
KB
-rw-r--r--
2025-06-04 09:21
textio.o
645.09
KB
-rw-r--r--
2025-06-04 09:22
timemodule.c
57.23
KB
-rw-r--r--
2024-03-19 22:46
timemodule.gcda
8.3
KB
-rw-r--r--
2025-06-04 09:21
timemodule.o
177.2
KB
-rw-r--r--
2025-06-04 09:22
tkappinit.c
4.71
KB
-rw-r--r--
2024-03-19 22:46
tkinter.h
881
B
-rw-r--r--
2024-03-19 22:46
unicodedata.c
44.69
KB
-rw-r--r--
2024-03-19 22:46
unicodedata_db.h
531.75
KB
-rw-r--r--
2024-03-19 22:46
unicodename_db.h
2.12
MB
-rw-r--r--
2024-03-19 22:46
winreparse.h
1.59
KB
-rw-r--r--
2024-03-19 22:46
xxlimited.c
9.23
KB
-rw-r--r--
2024-03-19 22:46
xxlimited_35.c
6.88
KB
-rw-r--r--
2024-03-19 22:46
xxmodule.c
12.56
KB
-rw-r--r--
2024-03-19 22:46
xxsubtype.c
10.78
KB
-rw-r--r--
2024-03-19 22:46
xxsubtype.gcda
4.45
KB
-rw-r--r--
2025-06-04 09:21
xxsubtype.o
54.38
KB
-rw-r--r--
2025-06-04 09:22
zlibmodule.c
46.52
KB
-rw-r--r--
2024-03-19 22:46
Save
Rename
#include "Python.h" #include <sys/resource.h> #include <sys/time.h> #include <string.h> #include <errno.h> #include <unistd.h> /* On some systems, these aren't in any header file. On others they are, with inconsistent prototypes. We declare the (default) return type, to shut up gcc -Wall; but we can't declare the prototype, to avoid errors when the header files declare it different. Worse, on some Linuxes, getpagesize() returns a size_t... */ #define doubletime(TV) ((double)(TV).tv_sec + (TV).tv_usec * 0.000001) /*[clinic input] module resource [clinic start generated code]*/ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=e89d38ed52609d7c]*/ /*[python input] class pid_t_converter(CConverter): type = 'pid_t' format_unit = '" _Py_PARSE_PID "' [python start generated code]*/ /*[python end generated code: output=da39a3ee5e6b4b0d input=0c1d19f640d57e48]*/ #include "clinic/resource.c.h" PyDoc_STRVAR(struct_rusage__doc__, "struct_rusage: Result from getrusage.\n\n" "This object may be accessed either as a tuple of\n" " (utime,stime,maxrss,ixrss,idrss,isrss,minflt,majflt,\n" " nswap,inblock,oublock,msgsnd,msgrcv,nsignals,nvcsw,nivcsw)\n" "or via the attributes ru_utime, ru_stime, ru_maxrss, and so on."); static PyStructSequence_Field struct_rusage_fields[] = { {"ru_utime", "user time used"}, {"ru_stime", "system time used"}, {"ru_maxrss", "max. resident set size"}, {"ru_ixrss", "shared memory size"}, {"ru_idrss", "unshared data size"}, {"ru_isrss", "unshared stack size"}, {"ru_minflt", "page faults not requiring I/O"}, {"ru_majflt", "page faults requiring I/O"}, {"ru_nswap", "number of swap outs"}, {"ru_inblock", "block input operations"}, {"ru_oublock", "block output operations"}, {"ru_msgsnd", "IPC messages sent"}, {"ru_msgrcv", "IPC messages received"}, {"ru_nsignals", "signals received"}, {"ru_nvcsw", "voluntary context switches"}, {"ru_nivcsw", "involuntary context switches"}, {0} }; static PyStructSequence_Desc struct_rusage_desc = { "resource.struct_rusage", /* name */ struct_rusage__doc__, /* doc */ struct_rusage_fields, /* fields */ 16 /* n_in_sequence */ }; typedef struct { PyTypeObject *StructRUsageType; } resourcemodulestate; static inline resourcemodulestate* get_resource_state(PyObject *module) { void *state = PyModule_GetState(module); assert(state != NULL); return (resourcemodulestate *)state; } static struct PyModuleDef resourcemodule; /*[clinic input] resource.getrusage who: int / [clinic start generated code]*/ static PyObject * resource_getrusage_impl(PyObject *module, int who) /*[clinic end generated code: output=8fad2880ba6a9843 input=5c857bcc5b9ccb1b]*/ { struct rusage ru; PyObject *result; if (getrusage(who, &ru) == -1) { if (errno == EINVAL) { PyErr_SetString(PyExc_ValueError, "invalid who parameter"); return NULL; } PyErr_SetFromErrno(PyExc_OSError); return NULL; } result = PyStructSequence_New( get_resource_state(module)->StructRUsageType); if (!result) return NULL; PyStructSequence_SET_ITEM(result, 0, PyFloat_FromDouble(doubletime(ru.ru_utime))); PyStructSequence_SET_ITEM(result, 1, PyFloat_FromDouble(doubletime(ru.ru_stime))); PyStructSequence_SET_ITEM(result, 2, PyLong_FromLong(ru.ru_maxrss)); PyStructSequence_SET_ITEM(result, 3, PyLong_FromLong(ru.ru_ixrss)); PyStructSequence_SET_ITEM(result, 4, PyLong_FromLong(ru.ru_idrss)); PyStructSequence_SET_ITEM(result, 5, PyLong_FromLong(ru.ru_isrss)); PyStructSequence_SET_ITEM(result, 6, PyLong_FromLong(ru.ru_minflt)); PyStructSequence_SET_ITEM(result, 7, PyLong_FromLong(ru.ru_majflt)); PyStructSequence_SET_ITEM(result, 8, PyLong_FromLong(ru.ru_nswap)); PyStructSequence_SET_ITEM(result, 9, PyLong_FromLong(ru.ru_inblock)); PyStructSequence_SET_ITEM(result, 10, PyLong_FromLong(ru.ru_oublock)); PyStructSequence_SET_ITEM(result, 11, PyLong_FromLong(ru.ru_msgsnd)); PyStructSequence_SET_ITEM(result, 12, PyLong_FromLong(ru.ru_msgrcv)); PyStructSequence_SET_ITEM(result, 13, PyLong_FromLong(ru.ru_nsignals)); PyStructSequence_SET_ITEM(result, 14, PyLong_FromLong(ru.ru_nvcsw)); PyStructSequence_SET_ITEM(result, 15, PyLong_FromLong(ru.ru_nivcsw)); if (PyErr_Occurred()) { Py_DECREF(result); return NULL; } return result; } static int py2rlimit(PyObject *limits, struct rlimit *rl_out) { PyObject *curobj, *maxobj; limits = PySequence_Tuple(limits); if (!limits) /* Here limits is a borrowed reference */ return -1; if (PyTuple_GET_SIZE(limits) != 2) { PyErr_SetString(PyExc_ValueError, "expected a tuple of 2 integers"); goto error; } curobj = PyTuple_GET_ITEM(limits, 0); maxobj = PyTuple_GET_ITEM(limits, 1); #if !defined(HAVE_LARGEFILE_SUPPORT) rl_out->rlim_cur = PyLong_AsLong(curobj); if (rl_out->rlim_cur == (rlim_t)-1 && PyErr_Occurred()) goto error; rl_out->rlim_max = PyLong_AsLong(maxobj); if (rl_out->rlim_max == (rlim_t)-1 && PyErr_Occurred()) goto error; #else /* The limits are probably bigger than a long */ rl_out->rlim_cur = PyLong_AsLongLong(curobj); if (rl_out->rlim_cur == (rlim_t)-1 && PyErr_Occurred()) goto error; rl_out->rlim_max = PyLong_AsLongLong(maxobj); if (rl_out->rlim_max == (rlim_t)-1 && PyErr_Occurred()) goto error; #endif Py_DECREF(limits); rl_out->rlim_cur = rl_out->rlim_cur & RLIM_INFINITY; rl_out->rlim_max = rl_out->rlim_max & RLIM_INFINITY; return 0; error: Py_DECREF(limits); return -1; } static PyObject* rlimit2py(struct rlimit rl) { if (sizeof(rl.rlim_cur) > sizeof(long)) { return Py_BuildValue("LL", (long long) rl.rlim_cur, (long long) rl.rlim_max); } return Py_BuildValue("ll", (long) rl.rlim_cur, (long) rl.rlim_max); } /*[clinic input] resource.getrlimit resource: int / [clinic start generated code]*/ static PyObject * resource_getrlimit_impl(PyObject *module, int resource) /*[clinic end generated code: output=98327b25061ffe39 input=a697cb0004cb3c36]*/ { struct rlimit rl; if (resource < 0 || resource >= RLIM_NLIMITS) { PyErr_SetString(PyExc_ValueError, "invalid resource specified"); return NULL; } if (getrlimit(resource, &rl) == -1) { PyErr_SetFromErrno(PyExc_OSError); return NULL; } return rlimit2py(rl); } /*[clinic input] resource.setrlimit resource: int limits: object / [clinic start generated code]*/ static PyObject * resource_setrlimit_impl(PyObject *module, int resource, PyObject *limits) /*[clinic end generated code: output=4e82ec3f34d013d1 input=6235a6ce23b4ca75]*/ { struct rlimit rl; if (resource < 0 || resource >= RLIM_NLIMITS) { PyErr_SetString(PyExc_ValueError, "invalid resource specified"); return NULL; } if (PySys_Audit("resource.setrlimit", "iO", resource, limits ? limits : Py_None) < 0) { return NULL; } if (py2rlimit(limits, &rl) < 0) { return NULL; } if (setrlimit(resource, &rl) == -1) { if (errno == EINVAL) PyErr_SetString(PyExc_ValueError, "current limit exceeds maximum limit"); else if (errno == EPERM) PyErr_SetString(PyExc_ValueError, "not allowed to raise maximum limit"); else PyErr_SetFromErrno(PyExc_OSError); return NULL; } Py_RETURN_NONE; } #ifdef HAVE_PRLIMIT /*[clinic input] resource.prlimit pid: pid_t resource: int [ limits: object ] / [clinic start generated code]*/ static PyObject * resource_prlimit_impl(PyObject *module, pid_t pid, int resource, int group_right_1, PyObject *limits) /*[clinic end generated code: output=ee976b393187a7a3 input=b77743bdccc83564]*/ { struct rlimit old_limit, new_limit; int retval; if (resource < 0 || resource >= RLIM_NLIMITS) { PyErr_SetString(PyExc_ValueError, "invalid resource specified"); return NULL; } if (PySys_Audit("resource.prlimit", "iiO", pid, resource, limits ? limits : Py_None) < 0) { return NULL; } if (group_right_1) { if (py2rlimit(limits, &new_limit) < 0) { return NULL; } retval = prlimit(pid, resource, &new_limit, &old_limit); } else { retval = prlimit(pid, resource, NULL, &old_limit); } if (retval == -1) { if (errno == EINVAL) { PyErr_SetString(PyExc_ValueError, "current limit exceeds maximum limit"); } else { PyErr_SetFromErrno(PyExc_OSError); } return NULL; } return rlimit2py(old_limit); } #endif /* HAVE_PRLIMIT */ /*[clinic input] resource.getpagesize -> int [clinic start generated code]*/ static int resource_getpagesize_impl(PyObject *module) /*[clinic end generated code: output=9ba93eb0f3d6c3a9 input=546545e8c1f42085]*/ { long pagesize = 0; #if defined(HAVE_GETPAGESIZE) pagesize = getpagesize(); #elif defined(HAVE_SYSCONF) && defined(_SC_PAGE_SIZE) pagesize = sysconf(_SC_PAGE_SIZE); #else # error "unsupported platform: resource.getpagesize()" #endif return pagesize; } /* List of functions */ static struct PyMethodDef resource_methods[] = { RESOURCE_GETRUSAGE_METHODDEF RESOURCE_GETRLIMIT_METHODDEF RESOURCE_PRLIMIT_METHODDEF RESOURCE_SETRLIMIT_METHODDEF RESOURCE_GETPAGESIZE_METHODDEF {NULL, NULL} /* sentinel */ }; /* Module initialization */ static int resource_exec(PyObject *module) { resourcemodulestate *state = get_resource_state(module); #define ADD_INT(module, value) \ do { \ if (PyModule_AddIntConstant(module, #value, value) < 0) { \ return -1; \ } \ } while (0) /* Add some symbolic constants to the module */ Py_INCREF(PyExc_OSError); if (PyModule_AddObject(module, "error", PyExc_OSError) < 0) { Py_DECREF(PyExc_OSError); return -1; } state->StructRUsageType = PyStructSequence_NewType(&struct_rusage_desc); if (state->StructRUsageType == NULL) { return -1; } if (PyModule_AddType(module, state->StructRUsageType) < 0) { return -1; } /* insert constants */ #ifdef RLIMIT_CPU ADD_INT(module, RLIMIT_CPU); #endif #ifdef RLIMIT_FSIZE ADD_INT(module, RLIMIT_FSIZE); #endif #ifdef RLIMIT_DATA ADD_INT(module, RLIMIT_DATA); #endif #ifdef RLIMIT_STACK ADD_INT(module, RLIMIT_STACK); #endif #ifdef RLIMIT_CORE ADD_INT(module, RLIMIT_CORE); #endif #ifdef RLIMIT_NOFILE ADD_INT(module, RLIMIT_NOFILE); #endif #ifdef RLIMIT_OFILE ADD_INT(module, RLIMIT_OFILE); #endif #ifdef RLIMIT_VMEM ADD_INT(module, RLIMIT_VMEM); #endif #ifdef RLIMIT_AS ADD_INT(module, RLIMIT_AS); #endif #ifdef RLIMIT_RSS ADD_INT(module, RLIMIT_RSS); #endif #ifdef RLIMIT_NPROC ADD_INT(module, RLIMIT_NPROC); #endif #ifdef RLIMIT_MEMLOCK ADD_INT(module, RLIMIT_MEMLOCK); #endif #ifdef RLIMIT_SBSIZE ADD_INT(module, RLIMIT_SBSIZE); #endif /* Linux specific */ #ifdef RLIMIT_MSGQUEUE ADD_INT(module, RLIMIT_MSGQUEUE); #endif #ifdef RLIMIT_NICE ADD_INT(module, RLIMIT_NICE); #endif #ifdef RLIMIT_RTPRIO ADD_INT(module, RLIMIT_RTPRIO); #endif #ifdef RLIMIT_RTTIME ADD_INT(module, RLIMIT_RTTIME); #endif #ifdef RLIMIT_SIGPENDING ADD_INT(module, RLIMIT_SIGPENDING); #endif /* target */ #ifdef RUSAGE_SELF ADD_INT(module, RUSAGE_SELF); #endif #ifdef RUSAGE_CHILDREN ADD_INT(module, RUSAGE_CHILDREN); #endif #ifdef RUSAGE_BOTH ADD_INT(module, RUSAGE_BOTH); #endif #ifdef RUSAGE_THREAD ADD_INT(module, RUSAGE_THREAD); #endif /* FreeBSD specific */ #ifdef RLIMIT_SWAP ADD_INT(module, RLIMIT_SWAP); #endif #ifdef RLIMIT_SBSIZE ADD_INT(module, RLIMIT_SBSIZE); #endif #ifdef RLIMIT_NPTS ADD_INT(module, RLIMIT_NPTS); #endif #ifdef RLIMIT_KQUEUES ADD_INT(module, RLIMIT_KQUEUES); #endif PyObject *v; if (sizeof(RLIM_INFINITY) > sizeof(long)) { v = PyLong_FromLongLong((long long) RLIM_INFINITY); } else { v = PyLong_FromLong((long) RLIM_INFINITY); } if (!v) { return -1; } if (PyModule_AddObject(module, "RLIM_INFINITY", v) < 0) { Py_DECREF(v); return -1; } return 0; #undef ADD_INT } static struct PyModuleDef_Slot resource_slots[] = { {Py_mod_exec, resource_exec}, {0, NULL} }; static int resourcemodule_traverse(PyObject *m, visitproc visit, void *arg) { Py_VISIT(get_resource_state(m)->StructRUsageType); return 0; } static int resourcemodule_clear(PyObject *m) { Py_CLEAR(get_resource_state(m)->StructRUsageType); return 0; } static void resourcemodule_free(void *m) { resourcemodule_clear((PyObject *)m); } static struct PyModuleDef resourcemodule = { PyModuleDef_HEAD_INIT, .m_name = "resource", .m_size = sizeof(resourcemodulestate), .m_methods = resource_methods, .m_slots = resource_slots, .m_traverse = resourcemodule_traverse, .m_clear = resourcemodule_clear, .m_free = resourcemodule_free, }; PyMODINIT_FUNC PyInit_resource(void) { return PyModuleDef_Init(&resourcemodule); }