We will use the lazy prerequisite ULIMIT_PROCESSES in a follow-up commit. With run_with_limited_processses() we can limit forking subprocesses and fail reliably in some test cases. Signed-off-by: Han Xin <hanxin.hx@xxxxxxxxxxxxx> --- t/test-lib.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/t/test-lib.sh b/t/test-lib.sh index 8ba5ca1534..655d6d543f 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -1816,6 +1816,22 @@ test_lazy_prereq ULIMIT_FILE_DESCRIPTORS ' run_with_limited_open_files true ' +run_with_limited_processses () { + # bash and ksh use "ulimit -u", dash uses "ulimit -p" + if test -n "$BASH_VERSION" + then + ulimit_max_process="-u" + elif test -n "$KSH_VERSION" + then + ulimit_max_process="-u" + fi + (ulimit ${ulimit_max_process-"-p"} 512 && "$@") +} + +test_lazy_prereq ULIMIT_PROCESSES ' + run_with_limited_processses true +' + build_option () { git version --build-options | sed -ne "s/^$1: //p" -- 2.36.1