@@ -86,11 +86,14 @@ private function handleSingleChildProcesses(): void
8686 } else {
8787 // child process
8888 $ this ->processChild ($ currentPage , $ totalPages , $ childProcessCounter );
89- exit (0 );
89+ register_shutdown_function (function () {
90+ posix_kill (getmypid (), SIGKILL );
91+ });
92+ exit ;
9093 }
9194
9295 $ pid = pcntl_waitpid ($ pid , $ status );
93- if (pcntl_wexitstatus ($ status ) != 0 ) {
96+ if (pcntl_wtermsig ($ status ) != 9 ) {
9497 $ this ->logger ->error ('Error with child process ' , [
9598 'pid ' => $ pid ,
9699 'exit_code ' => $ status
@@ -122,7 +125,7 @@ private function handleMultipleChildProcesses(): void
122125 // manage children
123126 while ($ childProcessCounter >= $ this ->maxChildrenProcess ) {
124127 $ pid = pcntl_wait ($ status );
125- if (pcntl_wexitstatus ($ status ) != 0 ) {
128+ if (pcntl_wtermsig ($ status ) != 9 ) {
126129 $ this ->logger ->error ('Error with child process ' , [
127130 'pid ' => $ pid ,
128131 'exit_code ' => $ status
@@ -143,7 +146,10 @@ private function handleMultipleChildProcesses(): void
143146 } else {
144147 // child process
145148 $ this ->processChild ($ currentPage , $ totalPages , $ childProcessCounter );
146- exit (0 );
149+ register_shutdown_function (function () {
150+ posix_kill (getmypid (), SIGKILL );
151+ });
152+ exit ;
147153 }
148154
149155 $ currentPage ++;
@@ -157,7 +163,7 @@ private function handleMultipleChildProcesses(): void
157163 while ($ childProcessCounter > 0 ) {
158164 $ pid = pcntl_wait ($ status );
159165 $ childProcessCounter --;
160- if (pcntl_wexitstatus ($ status ) != 0 ) {
166+ if (pcntl_wtermsig ($ status ) != 9 ) {
161167 $ this ->logger ->error ('Error with child process ' , [
162168 'pid ' => $ pid ,
163169 'exit_code ' => $ status
@@ -202,7 +208,10 @@ private function processChild(int $currentPage, int $totalPages, int $childProce
202208 'current_page ' => $ currentPage ,
203209 'exception ' => $ e
204210 ]);
205- exit (1 );
211+ register_shutdown_function (function () {
212+ posix_kill (getmypid (), SIGABRT );
213+ });
214+ exit ;
206215 }
207216
208217 $ this ->logger ->info ('Running child process ' , [
@@ -229,7 +238,10 @@ private function processChild(int $currentPage, int $totalPages, int $childProce
229238 }
230239
231240 if ($ itemProceed === 0 ) {
232- exit (1 );
241+ register_shutdown_function (function () {
242+ posix_kill (getmypid (), SIGABRT );
243+ });
244+ exit ;
233245 }
234246
235247 $ this ->logger ->info ('Finished child process ' , [
0 commit comments