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:rocess;
my %file;
my %work_GUI;
tie %file, 'Tie::Win32MemMap', {'Create' => 'MEM_NEW_SHARE','MapName'
=> 'carletto',};
$file{ciao} = 1;
Win32:rocess::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
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:rocess;
my %file;
my %work_GUI;
tie %file, 'Tie::Win32MemMap', {'Create' => 'MEM_NEW_SHARE','MapName'
=> 'carletto',};
$file{ciao} = 1;
Win32:rocess::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