When setting up a shared memory variable it works as expected for strings, int, bool etc but resources are just assigned there resource id which is useless when accessed from another process. So after looking around the guts of PHP it looks like the only way around it is to create some form of get/set_resource functions that manage the actual resource not it's string id, something like:
Code: Select all
// parent process
$key = 1;
$fd = fopen('file');
$id = shm_attach($key);
shm_put_var($id, 1, get_resource($fd));
$ipc->msgSend($pid, $key);
//child process
$key = $ipc->msgRecv();
$id = shm_attach($key);
$fd = set_resource(shm_get_var($id, 1));
fread($fd, 1034);
Has anyone come across this problem before or have any alternative ideas before I start work on a patch?