问题
I have a file, lets say file1.php, that within the script executes a file using: exec("php-cli -f _DAEMON.php")
after executing the exec()
command, it needs to run more code, the problem is that _DAEMON.php
as its name says, is a Daemon and it will never stop running, so it freezes file1.php without allowing the rest of the code to run.
Is there a way to allow the code to continue executing even if exec("php-cli -f _DAEMON.php")
has not finished. Or to detect if the code delays for more than x seconds/milliseconds, to continue?
Thanks.
回答1:
Maybe try using a socket (curl might work with a low timeout, not sure if it'll kill the script though offhand). Not ideal, will add some overhead.
http://phplens.com/phpeverywhere/?q=node/view/254
Also, doriana_gd was probably referring to something like node.js, server side javascript
来源:https://stackoverflow.com/questions/17500071/detect-when-a-script-delays-and-allow-it-to-skip-or-continue-in-php