I want to do this now, create a background thread after a particular request and keep running, and the thread will not block the current request.
In the implementation process, the discovery background thread will block the current request, causing the page to wait for no data, if the thread::d Etach, there will be an error as follows, the official document does not recommend the use of this method, do not know whether it is related to this error:
[Sun Sep 14 11:13:03.819745 2014] [Core:notice] [PID 14343] Ah00052:child PID 14847 Exit Signal Segmentation Fault (11)
Thank you!
Reply to discussion (solution)
No detach need to wait for the end of the child process to block the request
Detach is likely to conflict with existing extensions
It is recommended to use Message Queuing to implement this function
With what multi-threaded, directly in the background asynchronously run a script is finished, a code, and does not block the current process
The code is as follows:
EXEC ("PHP task.php >/dev/null &")
No detach need to wait for the end of the child process to block the request
Detach is likely to conflict with existing extensions
It is recommended to use Message Queuing to implement this function
The volume of communication data is relatively large, Message Queuing is not very appropriate, looked under the command pipeline to do more suitable.
With what multi-threaded, directly in the background asynchronously run a script is finished, a code, and does not block the current process
The code is as follows:
EXEC ("PHP task.php >/dev/null &")
This is also a way, but when the concurrency is large, I worry about the resources will be too much, the reason why I want to refer to the background to do this, because it takes a long time.