diff --git a/fork.php b/fork.php index e866c7a..cd1715d 100644 --- a/fork.php +++ b/fork.php @@ -19,8 +19,10 @@ class fork if (! function_exists ("pcntl_fork")) throw new \Exception ("Can't fork as PHP doesn't have the pcntl_fork", 500); - declare (ticks=1); - @pcntl_async_signals (true); + if (function_exists ("pcntl_async_signals")) + pcntl_async_signals (true); + else + declare (ticks=1); } /** Return the number of active PID @@ -89,6 +91,10 @@ class fork // there is an "echo" ob_start (); + // Catch the error messages from the application to not hang if triggered + // An other handler can be set in function to execute + set_error_handler (function () {}); + // Close the file handlers STDOUT/STDIN fclose (STDIN); fclose (STDOUT); diff --git a/tcpserver.php b/tcpserver.php index 994ce5f..098919e 100644 --- a/tcpserver.php +++ b/tcpserver.php @@ -357,6 +357,9 @@ class tcpserver // Will catch all the text messages from the application to not crash if // there is an "echo" ob_start (); + // Catch the error messages from the application to not hang if triggered + // An other handler can be set in function to execute + set_error_handler (function () {}); @fclose (STDIN); @fclose (STDOUT); @fclose (STDERR);