
SysV::SharedMem - SysV Shared memory made easy

version 0.008

use SysV::SharedMem; shared_open my $mem, '/path', '+>', size => 4096; vec($mem, 1, 16) = 34567; substr $mem, 45, 11, 'Hello World';
This module maps shared memory into a variable that can be read just like any other variable, and it can be written to using standard Perl techniques such as regexps and substr, as long as they don't change the length of the variable.

Open a shared memory object named $filename and attach it to $var. $filename must be the path to an existing file or undef, in which case the key option is used. $mode determines the read/write mode. It works the same as in open.
Beyond that it can take a number of optional named arguments:
This determines the size of the map. Must be set if a new shared memory object is being created.
This determines the permissions with which the segment is created (if $mode is '>' or '+>'). Default is 0600.
This determines the offset in the file that is mapped. Default is 0.
If $filename is undefined this parameter is used as the key to lookup the shared memory segment. It defaults to IPC_PRIVATE, which causes a new, anonymous shared memory segment to be created.
The project id, used to ensure the key generated from the filename is unique. Only the lower 8 bits are significant and may not be zero. Defaults to 1.
Marks a memory object to be removed. Shared memory has kernel persisence so it has to be explicitly disposed of. One can still use the object after marking it for removal.
Retrieve the properties of the shared memory object. It returns a hashref with these members:
Owner's user ID
Owner's group ID
Creator's user ID
Creator's group ID
Read/write permission
Size of segment in bytes
Process ID of last shared memory operation
Process ID of creator
Number of current attaches
Time of last attachment
Time of last detachment
Time of last of control structure
Change the (lower 9) modebits of the shared memory object.
Change the owning uid and optionally gid of the shared memory object.

Leon Timmermans <leont@cpan.org>

This software is copyright (c) 2010 by Leon Timmermans.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.