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
#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.