Add (undocumented) option 'rsrclimit' to limit resource usage.

This commit is contained in:
Sei Lisa 2017-05-05 20:37:38 +02:00
parent f1b05dd2ff
commit 6fe4cc3ae8

13
main.py
View file

@ -257,7 +257,7 @@ Case insensitive.
Firestorm, but not recommended. Note that the operand to
switch() may be evaluated more than once.
ErrMissingDefault + Throw an error in case the 'default:' label of a switch
statement is missing.
statement is missing. Only meaningful with EnableSwitch.
FuncOverride - Allow duplicate function definitions to override the
previous definition. For compatibility with Firestorm's
optimizer.
@ -322,7 +322,9 @@ validoptions = frozenset(('extendedglobalexpr','breakcont','extendedtypecast',
'lazylists','enableswitch','errmissingdefault','funcoverride','optimize',
'optsigns','optfloats','constfold','dcr','shrinknames','addstrings',
'foldtabs','warntabs','processpre','explicitcast','listlength',
'help','lso','expr'
'help',
# undocumented
'lso','expr','rsrclimit',
# 'clear' is handled as a special case
))
@ -493,6 +495,13 @@ def main(argv):
try:
if 'rsrclimit' in options:
import resource
resource.setrlimit(resource.RLIMIT_CPU, (5, 5))
resource.setrlimit(resource.RLIMIT_STACK, (393216, 393216))
resource.setrlimit(resource.RLIMIT_DATA, (4096, 4096))
resource.setrlimit(resource.RLIMIT_AS, (20001000, 20001000))
if 'lso' in options:
lslopt.lslcommon.LSO = True
options.remove('lso')