diff --git a/src/Console/Command/Compile.php b/src/Console/Command/Compile.php
index cc8573c88..06d004466 100644
--- a/src/Console/Command/Compile.php
+++ b/src/Console/Command/Compile.php
@@ -609,35 +609,37 @@ private function bumpOpenFileDescriptorLimit(Box $box, SymfonyStyle $io): callab
{
$filesCount = count($box) + 128; // Add a little extra for good measure
- if (function_exists('posix_getrlimit') && function_exists('posix_setrlimit')) {
- $softLimit = posix_getrlimit()['soft openfiles'];
- $hardLimit = posix_getrlimit()['hard openfiles'];
-
- if ($softLimit < $filesCount) {
- $io->writeln(
- sprintf(
- '[debug] Increased the maximum number of open file descriptors from ("%s", "%s") to ("%s", "%s")'
- .'',
- $softLimit,
- $hardLimit,
- $filesCount,
- 'unlimited'
- ),
- OutputInterface::VERBOSITY_DEBUG
- );
-
- posix_setrlimit(
- POSIX_RLIMIT_NOFILE,
- $filesCount,
- 'unlimited' === $hardLimit ? POSIX_RLIMIT_INFINITY : $hardLimit
- );
- }
- } else {
+ if (false === function_exists('posix_getrlimit') || false === function_exists('posix_setrlimit')) {
$io->writeln(
'[debug] Could not check the maximum number of open file descriptors: the functions "posix_getrlimit()" and '
.'"posix_setrlimit" could not be found.',
OutputInterface::VERBOSITY_DEBUG
);
+
+ return function () {};
+ }
+
+ $softLimit = posix_getrlimit()['soft openfiles'];
+ $hardLimit = posix_getrlimit()['hard openfiles'];
+
+ if ($softLimit < $filesCount) {
+ $io->writeln(
+ sprintf(
+ '[debug] Increased the maximum number of open file descriptors from ("%s", "%s") to ("%s", "%s")'
+ .'',
+ $softLimit,
+ $hardLimit,
+ $filesCount,
+ 'unlimited'
+ ),
+ OutputInterface::VERBOSITY_DEBUG
+ );
+
+ posix_setrlimit(
+ POSIX_RLIMIT_NOFILE,
+ $filesCount,
+ 'unlimited' === $hardLimit ? POSIX_RLIMIT_INFINITY : $hardLimit
+ );
}
return function () use ($io, $softLimit, $hardLimit): void {