Win32MemMap problem

Discussion in 'Perl' started by Carlo Filippini, Aug 11, 2004.

  1. 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
    Carlo Filippini, Aug 11, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas Suurkuusk
    Replies:
    0
    Views:
    3,952
    Andreas Suurkuusk
    Jul 27, 2003
  2. Ted Miller
    Replies:
    0
    Views:
    5,140
    Ted Miller
    Sep 13, 2003
  3. Merek
    Replies:
    0
    Views:
    1,946
    Merek
    Dec 3, 2003
  4. Scott Meddows
    Replies:
    1
    Views:
    381
    John Saunders
    Jun 8, 2004
  5. Mike

    Problem problem problem :( Need Help

    Mike, May 7, 2004, in forum: ASP General
    Replies:
    2
    Views:
    534
    Bullschmidt
    May 11, 2004
Loading...

Share This Page