1################################################################################ 2# 3# Version 2.x, Copyright (C) 2007-2013, Marcus Holland-Moritz <mhx@cpan.org>. 4# Version 1.x, Copyright (C) 1997, Graham Barr <gbarr@pobox.com>. 5# 6# This program is free software; you can redistribute it and/or 7# modify it under the same terms as Perl itself. 8# 9################################################################################ 10 11package IPC::SysV; 12 13use strict; 14use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION $AUTOLOAD); 15use Carp; 16use Config; 17 18require Exporter; 19@ISA = qw(Exporter); 20 21$VERSION = '2.07'; 22 23# To support new constants, just add them to @EXPORT_OK 24# and the C/XS code will be generated automagically. 25@EXPORT_OK = (qw( 26 27 GETALL GETNCNT GETPID GETVAL GETZCNT 28 29 IPC_ALLOC IPC_CREAT IPC_EXCL IPC_GETACL IPC_INFO IPC_LOCKED 30 IPC_M IPC_NOERROR IPC_NOWAIT IPC_PRIVATE IPC_R IPC_RMID 31 IPC_SET IPC_SETACL IPC_SETLABEL IPC_STAT IPC_W IPC_WANTED 32 33 MSG_EXCEPT MSG_FWAIT MSG_INFO MSG_LOCKED MSG_MWAIT MSG_NOERROR 34 MSG_QWAIT MSG_R MSG_RWAIT MSG_STAT MSG_W MSG_WAIT MSG_WWAIT 35 36 SEM_A SEM_ALLOC SEM_DEST SEM_ERR SEM_INFO SEM_ORDER SEM_R 37 SEM_STAT SEM_UNDO 38 39 SETALL SETVAL 40 41 SHMLBA 42 43 SHM_A SHM_CLEAR SHM_COPY SHM_DCACHE SHM_DEST SHM_ECACHE 44 SHM_FMAP SHM_HUGETLB SHM_ICACHE SHM_INFO SHM_INIT SHM_LOCK 45 SHM_LOCKED SHM_MAP SHM_NORESERVE SHM_NOSWAP SHM_R SHM_RDONLY 46 SHM_REMAP SHM_REMOVED SHM_RND SHM_SHARE_MMU SHM_SHATTR 47 SHM_SIZE SHM_STAT SHM_UNLOCK SHM_W 48 49 S_IRUSR S_IWUSR S_IXUSR S_IRWXU 50 S_IRGRP S_IWGRP S_IXGRP S_IRWXG 51 S_IROTH S_IWOTH S_IXOTH S_IRWXO 52 53 ENOSPC ENOSYS ENOMEM EACCES 54 55), qw( 56 57 ftok shmat shmdt memread memwrite 58 59)); 60 61%EXPORT_TAGS = ( 62 all => [@EXPORT, @EXPORT_OK], 63); 64 65sub AUTOLOAD 66{ 67 my $constname = $AUTOLOAD; 68 $constname =~ s/.*:://; 69 die "&IPC::SysV::_constant not defined" if $constname eq '_constant'; 70 my ($error, $val) = _constant($constname); 71 if ($error) { 72 my (undef, $file, $line) = caller; 73 die "$error at $file line $line.\n"; 74 } 75 { 76 no strict 'refs'; 77 *$AUTOLOAD = sub { $val }; 78 } 79 goto &$AUTOLOAD; 80} 81 82BOOT_XS: { 83 # If I inherit DynaLoader then I inherit AutoLoader and I DON'T WANT TO 84 require DynaLoader; 85 86 # DynaLoader calls dl_load_flags as a static method. 87 *dl_load_flags = DynaLoader->can('dl_load_flags'); 88 89 do { 90 __PACKAGE__->can('bootstrap') || \&DynaLoader::bootstrap 91 }->(__PACKAGE__, $VERSION); 92} 93 941; 95 96__END__ 97 98=head1 NAME 99 100IPC::SysV - System V IPC constants and system calls 101 102=head1 SYNOPSIS 103 104 use IPC::SysV qw(IPC_STAT IPC_PRIVATE); 105 106=head1 DESCRIPTION 107 108C<IPC::SysV> defines and conditionally exports all the constants 109defined in your system include files which are needed by the SysV 110IPC calls. Common ones include 111 112 IPC_CREAT IPC_EXCL IPC_NOWAIT IPC_PRIVATE IPC_RMID IPC_SET IPC_STAT 113 GETVAL SETVAL GETPID GETNCNT GETZCNT GETALL SETALL 114 SEM_A SEM_R SEM_UNDO 115 SHM_RDONLY SHM_RND SHMLBA 116 117and auxiliary ones 118 119 S_IRUSR S_IWUSR S_IRWXU 120 S_IRGRP S_IWGRP S_IRWXG 121 S_IROTH S_IWOTH S_IRWXO 122 123but your system might have more. 124 125=over 4 126 127=item ftok( PATH ) 128 129=item ftok( PATH, ID ) 130 131Return a key based on PATH and ID, which can be used as a key for 132C<msgget>, C<semget> and C<shmget>. See L<ftok(3)>. 133 134If ID is omitted, it defaults to C<1>. If a single character is 135given for ID, the numeric value of that character is used. 136 137=item shmat( ID, ADDR, FLAG ) 138 139Attach the shared memory segment identified by ID to the address 140space of the calling process. See L<shmat(2)>. 141 142ADDR should be C<undef> unless you really know what you're doing. 143 144=item shmdt( ADDR ) 145 146Detach the shared memory segment located at the address specified 147by ADDR from the address space of the calling process. See L<shmdt(2)>. 148 149=item memread( ADDR, VAR, POS, SIZE ) 150 151Reads SIZE bytes from a memory segment at ADDR starting at position POS. 152VAR must be a variable that will hold the data read. Returns true if 153successful, or false if there is an error. memread() taints the variable. 154 155=item memwrite( ADDR, STRING, POS, SIZE ) 156 157Writes SIZE bytes from STRING to a memory segment at ADDR starting at 158position POS. If STRING is too long, only SIZE bytes are used; if STRING 159is too short, nulls are written to fill out SIZE bytes. Returns true if 160successful, or false if there is an error. 161 162=back 163 164=head1 SEE ALSO 165 166L<IPC::Msg>, L<IPC::Semaphore>, L<IPC::SharedMem>, L<ftok(3)>, L<shmat(2)>, L<shmdt(2)> 167 168=head1 AUTHORS 169 170Graham Barr <gbarr@pobox.com>, 171Jarkko Hietaniemi <jhi@iki.fi>, 172Marcus Holland-Moritz <mhx@cpan.org> 173 174=head1 COPYRIGHT 175 176Version 2.x, Copyright (C) 2007-2013, Marcus Holland-Moritz. 177 178Version 1.x, Copyright (c) 1997, Graham Barr. 179 180This program is free software; you can redistribute it and/or 181modify it under the same terms as Perl itself. 182 183=cut 184 185