Firstly, out of the box I don't think there's a way to share memory between PHP and some slave executable. So...
One of two possible scenarios, going from easiest to hardest:
1) Modify the C++ program to support a command-line option to do a private-key encryption of the temp/output file. Ideally, your PHP script would call the program with a random key so it would be able to pick up the tempfile, decrypt it and remove it.
2) Harder, but more secure: wrap the C++ code in a PHP extension that will be utterly private to your scripting.
Both of these assume that your tempfile is randomly named, BTW, so multiple threads won't write over each other's data.
RW
===========================================
http://badblue.com
Small footprint P2P web server for Windows,
File-sharing, PHP, wireless apps & more