|
Boost : |
Subject: [boost] [interprocess] Sharing shared_memory_object across processes?
From: Joseph Van Riper (fleeb.fantastique_at_[hidden])
Date: 2012-04-25 14:26:01
I either do not understand what I am seeing, or I may have stumbled upon a
bug, at least in a Windows environment. Or, of course, my expectations may
be unrealistic.
The short of this is that when I create a
boost::interprocess::shared_memory_object that isn't removed for the
duration of the program's run, the reading program's run can't seem to open
the shared_memory_object, despite creating a
boost::interprocess::permissions object and calling 'set_unrestricted()'.
I get an exception indicating that access is denied.
If nothing else, the code I've provided is an interprocess version of the
classic read-writer's problem, second version (writers preferred). It may
be of use to someone with a little cleaning.
Environment:
Compiler: MSVC++ 10
OS: Win 7 Pro, 64-bit.
Steps to reproduce:
1. In VC++ 10, create an empty command-line project.
2. Replace contents of your .cpp with the code in this e-mail.
3. Compile.
4. Run the executable twice, first with an argument, next without.
Expected results:
The executable run without arguments indicates how much data was
transferred on the same line.
Actual results:
The executable run without arguments complains that access is denied.
NOTE:
If you #define BOLD_NEW_TEST and recompile, this program runs according to
expectations. This causes the objects to be compiled in a way where the
shared_memory_objects only last for as long as it takes to write or read
the data. I suspect this shouldn't be necessary, but perhaps I'm wrong.
The error is especially peculiar to me, as I can open the file itself with
a text editor. It doesn't seem like it should be denied.
- Trey
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk