File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,7 +36,16 @@ public function afterInit(): void
3636 return ;
3737 }
3838 self ::$ afterInitDone = true ;
39- f_passthru ('ulimit -n 2048 ' ); // zig opens extra file descriptors, so when a lot of extensions are built statically, 1024 is not enough
39+ // zig opens extra file descriptors, so when a lot of extensions are built statically, 1024 is not enough
40+ if (function_exists ('posix_setrlimit ' ) && function_exists ('posix_getrlimit ' )) {
41+ $ limits = posix_getrlimit ();
42+ $ hard = (int ) ($ limits ['hardopenfiles ' ] ?? 2048 );
43+ $ soft = (int ) ($ limits ['softopenfiles ' ] ?? 1024 );
44+ $ target = min (max ($ soft , 2048 ), $ hard > 0 ? $ hard : 2048 );
45+ if ($ target > $ soft ) {
46+ posix_setrlimit (POSIX_RLIMIT_NOFILE , $ target , $ hard );
47+ }
48+ }
4049 $ cflags = getenv ('SPC_DEFAULT_CFLAGS ' ) ?: '' ;
4150 $ cxxflags = getenv ('SPC_DEFAULT_CXXFLAGS ' ) ?: '' ;
4251 $ extraCflags = getenv ('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS ' ) ?: '' ;
You can’t perform that action at this time.
0 commit comments