Win32MemMap problem

C

Carlo Filippini

Hi
I am trying to use Tie::Win32MemMap as shown in O'Reilly
"Mastering Perl/Tk". I need the two processes to share some
variables, bidirectionaly. So I generate two MemMap, one "owned" by
the parent and one in the child process. For some reason the parent
process can not "see" the hash created by the child process. I use
v5.8.3 built for MSWin32-x86-multi-thread.

Below you can find the code for both process and the result.
Anybody can help?
Thanks
Carlo

########################################################
################## C:\Auto_test\test\map.pl (parent):
##############
########################################################

#!D:\Perl\bin\perl -w

use Tie::Win32MemMap;
use Win32;
use Win32::process;


my %file;
my %work_GUI;
tie %file, 'Tie::Win32MemMap', {'Create' => 'MEM_NEW_SHARE','MapName'
=> 'carletto',};
$file{ciao} = 1;
Win32::process::Create(
my $child,
'C:\Perl\bin\perl.exe',
'C:\Auto_test\test\map2.pl',
0,
NORMAL_PRIORITY_CLASS,
'.',
) or die Win32::FormatMessage(Win32::GetLastError);
select(undef, undef, undef, 3); #make sure the child has time enough

tie (%work_GUI, 'Tie::Win32MemMap', { Create => MEM_VIEW_SHARE,
MapName => 'work_GUI'});
print "Map says $file{ciao}\n";
print "Map says $work_GUI{ciao} \n";

########################################################
################## C:\Auto_test\test\map2.pl (child):
##############
########################################################

#!D:\Perl\bin\perl -w

use Tie::Win32MemMap;

my %file;
my %GUI_work;
tie %file, 'Tie::Win32MemMap', {
'Create' => 'MEM_VIEW_SHARE',
'MapName' => 'carletto',
};
tie (%work_GUI, 'Tie::Win32MemMap', { Create => MEM_NEW_SHARE, MapName
=> 'work_GUI', Size => 10000 });
$work_GUI{ciao} = "2";
print "Map2 says $file{ciao}\n";
print "Map2 says $work_GUI{ciao} \n";
select(undef, undef, undef, 6);


#################################################################

---------- Capture Output ----------
"C:\Perl\bin\perl.exe" map.pl
No such Shared Memory space: //MemMap/work_GUI
at map.pl line 22

Terminated with exit code 255
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top