Fork / TCPServer : manage the background job to catch the errors triggered by PHP

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5981 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2020-05-10 19:29:58 +00:00
parent 9557bb2302
commit e19c6cc9f2
2 changed files with 11 additions and 2 deletions

View File

@@ -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);
if (function_exists ("pcntl_async_signals"))
pcntl_async_signals (true);
else
declare (ticks=1);
@pcntl_async_signals (true);
}
/** 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);

View File

@@ -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);