File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 99class Pool{
1010
1111 protected int $ max_childs ;
12+ protected bool $ kill_childs ;
1213 protected array $ childs = [];
1314 protected array $ queue = [];
1415 protected int $ pid ;
@@ -18,14 +19,15 @@ class Pool{
1819 private bool $ is_resolving_queue = false ;
1920 private bool $ need_tick = true ;
2021
21- public function __construct (?int $ max_childs = null )
22+ public function __construct (?int $ max_childs = null , bool $ kill_childs = true )
2223 {
2324 if (!extension_loaded ("pcntl " )){
2425 throw new MissingExtensionException ("PCNTL Extension is missing in your PHP build " );
2526 }
2627 $ this ->pid = getmypid ();
2728 $ max_childs ??= (self ::getCoresCount () ?? 1 ) * 50 ;
2829 $ this ->max_childs = $ max_childs ;
30+ $ this ->kill_childs = $ kill_childs ;
2931
3032 register_tick_function ([$ this , "tick " ]);
3133 pcntl_signal (SIGCHLD , SIG_IGN ); // ignores the SIGCHLD signal
@@ -74,7 +76,9 @@ protected function _parallel(Closure $closure, ...$args)
7476 else {
7577 // we are the child
7678 $ this ->is_parent = false ;
77- pcntl_signal (SIGINT , SIG_IGN );
79+ if (!$ this ->kill_childs ) {
80+ pcntl_signal (SIGINT , SIG_IGN );
81+ }
7882 $ closure ($ args );
7983 exit ;
8084 }
You can’t perform that action at this time.
0 commit comments