@@ -86,11 +86,14 @@ private function handleSingleChildProcesses(): void
86
86
} else {
87
87
// child process
88
88
$ this ->processChild ($ currentPage , $ totalPages , $ childProcessCounter );
89
- exit (0 );
89
+ register_shutdown_function (function () {
90
+ posix_kill (getmypid (), SIGKILL );
91
+ });
92
+ exit ;
90
93
}
91
94
92
95
$ pid = pcntl_waitpid ($ pid , $ status );
93
- if (pcntl_wexitstatus ($ status ) != 0 ) {
96
+ if (pcntl_wtermsig ($ status ) != 9 ) {
94
97
$ this ->logger ->error ('Error with child process ' , [
95
98
'pid ' => $ pid ,
96
99
'exit_code ' => $ status
@@ -122,7 +125,7 @@ private function handleMultipleChildProcesses(): void
122
125
// manage children
123
126
while ($ childProcessCounter >= $ this ->maxChildrenProcess ) {
124
127
$ pid = pcntl_wait ($ status );
125
- if (pcntl_wexitstatus ($ status ) != 0 ) {
128
+ if (pcntl_wtermsig ($ status ) != 9 ) {
126
129
$ this ->logger ->error ('Error with child process ' , [
127
130
'pid ' => $ pid ,
128
131
'exit_code ' => $ status
@@ -143,7 +146,10 @@ private function handleMultipleChildProcesses(): void
143
146
} else {
144
147
// child process
145
148
$ this ->processChild ($ currentPage , $ totalPages , $ childProcessCounter );
146
- exit (0 );
149
+ register_shutdown_function (function () {
150
+ posix_kill (getmypid (), SIGKILL );
151
+ });
152
+ exit ;
147
153
}
148
154
149
155
$ currentPage ++;
@@ -157,7 +163,7 @@ private function handleMultipleChildProcesses(): void
157
163
while ($ childProcessCounter > 0 ) {
158
164
$ pid = pcntl_wait ($ status );
159
165
$ childProcessCounter --;
160
- if (pcntl_wexitstatus ($ status ) != 0 ) {
166
+ if (pcntl_wtermsig ($ status ) != 9 ) {
161
167
$ this ->logger ->error ('Error with child process ' , [
162
168
'pid ' => $ pid ,
163
169
'exit_code ' => $ status
@@ -202,7 +208,10 @@ private function processChild(int $currentPage, int $totalPages, int $childProce
202
208
'current_page ' => $ currentPage ,
203
209
'exception ' => $ e
204
210
]);
205
- exit (1 );
211
+ register_shutdown_function (function () {
212
+ posix_kill (getmypid (), SIGABRT );
213
+ });
214
+ exit ;
206
215
}
207
216
208
217
$ this ->logger ->info ('Running child process ' , [
@@ -229,7 +238,10 @@ private function processChild(int $currentPage, int $totalPages, int $childProce
229
238
}
230
239
231
240
if ($ itemProceed === 0 ) {
232
- exit (1 );
241
+ register_shutdown_function (function () {
242
+ posix_kill (getmypid (), SIGABRT );
243
+ });
244
+ exit ;
233
245
}
234
246
235
247
$ this ->logger ->info ('Finished child process ' , [
0 commit comments