зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1616790 - Keep the hard limit for `ulimit -n` unchanged. r=froydnj
The hard limit prevents program to set a value higher than the soft limit for themselves, and it turns out Firefox does that. Also, keep the soft limit to its original value if it was already less than 1024. Differential Revision: https://phabricator.services.mozilla.com/D63623 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
a19a0ef372
Коммит
4ae6ad3247
|
@ -692,8 +692,20 @@ def main(args):
|
||||||
# Processes spawned by this one will inherit the limit set here.
|
# Processes spawned by this one will inherit the limit set here.
|
||||||
try:
|
try:
|
||||||
import resource
|
import resource
|
||||||
limit = int(os.environ.get('MOZ_LIMIT_NOFILE', '1024'))
|
# Keep the hard limit the same, though, allowing processes to change their
|
||||||
resource.setrlimit(resource.RLIMIT_NOFILE, (limit, limit))
|
# soft limit if they need to (Firefox does, for instance).
|
||||||
|
(soft, hard) = resource.getrlimit(resource.RLIMIT_NOFILE)
|
||||||
|
limit = os.environ.get('MOZ_LIMIT_NOFILE')
|
||||||
|
if limit:
|
||||||
|
limit = int(limit)
|
||||||
|
else:
|
||||||
|
# If no explicit limit is given, use 1024 if it's less than the current
|
||||||
|
# soft limit. For instance, the default on macOS is 256, so we'd pick
|
||||||
|
# that rather than 1024.
|
||||||
|
limit = min(soft, 1024)
|
||||||
|
# Now apply the limit, if it's different from the original one.
|
||||||
|
if limit != soft:
|
||||||
|
resource.setrlimit(resource.RLIMIT_NOFILE, (limit, hard))
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# The resource module is UNIX only.
|
# The resource module is UNIX only.
|
||||||
pass
|
pass
|
||||||
|
|
Загрузка…
Ссылка в новой задаче