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:
10
fork.php
10
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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user