IPC::SysV#
System V IPC constants and the system calls Perl’s builtins do not cover.
Perl’s core already provides msgget/msgctl/msgsnd/msgrcv, semget/semctl/semop and shmget/shmctl/shmread/shmwrite as builtins. What IPC::SysV adds on top is the constant table (IPC_CREAT, SEM_UNDO, SHM_RDONLY, …), the ftok key generator, shared-memory attach/detach, and the pack/unpack pair each of IPC::Msg::stat, IPC::Semaphore::stat and IPC::SharedMem::stat uses to move a struct msqid_ds / semid_ds / shmid_ds across the Perl boundary.
IPC::Msg, IPC::Semaphore and IPC::SharedMem are pure Perl on top of this module; @EXPORT_OK, %EXPORT_TAGS and the AUTOLOAD that resolves a constant name come from IPC/SysV.pm.
use IPC::SysV qw(IPC_PRIVATE IPC_CREAT IPC_RMID S_IRUSR S_IWUSR ftok shmat shmdt memread memwrite);
my $key = ftok($0, 1); # a key derived from a file
my $id = shmget(IPC_PRIVATE, 64, IPC_CREAT | S_IRUSR | S_IWUSR) // die "shmget: $!";
my $addr = shmat($id, undef, 0) // die "shmat: $!"; # attach: an address
memwrite($addr, "hello", 0, 5) or die;
memread($addr, my $buf, 0, 5) or die;
print "read back '$buf'\n"; # read back 'hello'
shmdt($addr);
shmctl($id, IPC_RMID, 0);
This is a native implementation of the XS half of IPC::SysV 2.09; IPC/SysV.pm and the three object modules are used unchanged. Nothing is exported by default; ask for names, or for everything with :all.
Differences from upstream#
None.
Functions#
Keys#
ftok#
ftok($path, $id = undef) - derive a System V IPC key from an existing file and a project id.