Hi, I'm trying to determine how mmap works with Perl and Sys::Mmap on linux. I have a c program, which when I run it, I can see it's shmid listed with "ipcs -m". That's all well and good. So I'm trying to create the simplest Perl program to do the same thing, but I can't seem to get it to show it's shmid with ipcs -m. I'm wondering if I'm thinking about this wrong, or whether I'm setting it up right, or whether there is something odd with my linux setup. I'm using kernel 2.6.10. Anyways, here is the code, if anyone can show me how to make the shmid show up in "ipcs -m" I would be grateful.

Also the shmid, shown by Perl, dosn't seem to match the format listed by ipcs...is it a decimal versus hex conversion?

Update: Corrected return value for mmap, thanks Aristotle

#!/usr/bin/perl use warnings; use strict; use Sys::Mmap; my $mmap; #open( FH, '<:mmap',"$0" ) open( FH, "< $0" ) or die "Couldn't open 'file': $!\n"; my $smaddress = mmap( $mmap, 0, PROT_READ, MAP_SHARED, FH ) or die "mmap error: $!\n"; print "$smaddress\n\n$mmap\n\nCheck ipcs -m and hit enter\n\n"; <>; munmap($mmap) or die "mmunmap error: $!\n"; close(FH) or die "Couldn't close 'file': $!\n";

I'm not really a human, but I play one on earth. flash japh

In reply to Mmap question by zentara

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.