|Think about Loose Coupling|
Since you are testing for MS and treating the problem different for *nix and MS, you may not know about '/dev/shm' which most modern *nix have. If you do a 'df' you'll see if it's there. What this does is allow you to share information between different processes in *nix. It treats memory as a separate filesystem for you to 'open/read/write/close' in memory files without going to disk.
In my testing, I've found it to be 2 or more times faster than using disk, and it's 'cleaned-up' on re-boot.
I don't think the method you're using in *nix will work, since there is no relationship between the process created with 'open' and your process. Why it works in MS, someone else will have to explain. If you use 'fork', all variables are copied to the new process, so you can say:
and it will be available in the new 'fork'ed process.
"Well done is better than well said." - Benjamin Franklin