In fixing a website for someone, I've run into the following problem:
In order to process some data, it calls exec("/usr/bin/php /path/to/file.php input.dat")
, while the file.php
that gets called contains an include("config.php")
, which, in turn, contains a call to session_start()
.
The probl开发者_开发知识库em that occurs is a deadlock waiting for flock("/tmp/sess_XXXXXX")
. The parent script locks the session file, then the exec
'ed script attempts to continue the same session, locking that file again, but getting deadlocked waiting for it.
I've tried putting the following at the very beginning of the the exec
'ed script, but to no avail:
session_save_path("/tmp/alt_session");
session_id("NOTHING");
Obivously there's something distinctly absurd about calling exec("php ...")
from within a php script, but that's an argument for another day, and not something I can change here. Also, while I'm free to change the file that gets run under exec
, changing config.php
would create a some other headaches that I'd prefer to avoid.
Any other options, or am I missing something important?
There is a php bug that I believe relates to your problem.
In short, the solution was to run session_write_close()
before file_get_contents()
, (which in your case would be exec()
)
精彩评论