POSIX::RT::SharedMem - Create/open or unlink POSIX shared memory objects in Perl
use POSIX::RT::SharedMem qw/shared_open/; shared_open my $map, '/some_file', '+>', size => 1024, perms => oct(777);
This module maps POSIX 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.
Map the shared memory object
$map. For portable use, a shared memory object should be identified by a name of the form '/somename'; that is, a string consisting of an initial slash, followed by one or more characters, none of which are slashes.
$mode determines the read/write mode. It works the same as in open and map_file.
Beyond that it can take three named arguments:
This determines the size of the map. If the map is map has writing permissions and the file is smaller than the given size it will be lengthened. Defaults to the length of the file and fails if it is zero. It is mandatory when using mode
This determines the permissions with which the file is created (if $mode is
+>). Default is 0600.
This determines the offset in the file that is mapped. Default is
Extra flags that are used when opening the shared memory object (e.g.
Remove the shared memory object $name from the namespace. Note that while the shared memory object can't be opened anymore after this, it doesn't remove the contents until all processes have closed it.
This is a rather similar module that works with SysV shared memory. SysV has confusing ideas of how to identify a segment, as well as having various special case functions that are handled by standard filehandle calls in POSIX shared memory. This module should usually be preferred unless portability requires otherwise.
This is used to map the shared memory handle into a scalar. If your processes have a parent-child relationship, you may want to look at
Leon Timmermans <email@example.com>
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.