From edde251d58ae9a2a4b9d80f143b0a285f60957b1 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Sat, 3 Aug 2019 21:40:57 +0100 Subject: [PATCH] issue #549: ansible: reduce risk by capping RLIM_INFINITY --- ansible_mitogen/process.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ansible_mitogen/process.py b/ansible_mitogen/process.py index 99e07aee..0a183e6a 100644 --- a/ansible_mitogen/process.py +++ b/ansible_mitogen/process.py @@ -246,7 +246,14 @@ def increase_open_file_limit(): limit is much higher. """ soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE) - LOG.debug('inherited open file limits: soft=%d hard=%d', soft, hard) + if hard == resource.RLIM_INFINITY: + hard_s = '(infinity)' + # cap in case of O(RLIMIT_NOFILE) algorithm in some subprocess. + hard = 524288 + else: + hard_s = str(hard) + + LOG.debug('inherited open file limits: soft=%d hard=%s', soft, hard_s) if soft >= hard: LOG.debug('max open files already set to hard limit: %d', hard) return