| Conditions | 7 |
| Paths | 10 |
| Total Lines | 27 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | public static function report(array $stats) |
||
| 21 | { |
||
| 22 | $pid = null; |
||
| 23 | if (extension_loaded('pcntl')) { |
||
| 24 | declare(ticks = 1); |
||
| 25 | $pid = pcntl_fork(); |
||
| 26 | } |
||
| 27 | |||
| 28 | if (is_null($pid) || $pid === -1) { |
||
| 29 | // Fork fails or there is no `pcntl` extension. |
||
| 30 | try { |
||
| 31 | Request::post(self::ENDPOINT, $stats); |
||
| 32 | } catch (\Throwable $e) { |
||
| 33 | // pass |
||
| 34 | } |
||
| 35 | } elseif ($pid === 0) { |
||
| 36 | // Child process. |
||
| 37 | posix_setsid(); |
||
| 38 | try { |
||
| 39 | Request::post(self::ENDPOINT, $stats); |
||
| 40 | } catch (\Throwable $e) { |
||
| 41 | // pass |
||
| 42 | } |
||
| 43 | // Close child process after doing job. |
||
| 44 | exit(0); |
||
| 45 | } |
||
| 46 | } |
||
| 47 | } |
||
| 48 |