| 1 |
.\" -*- mode: troff; coding: utf-8 -*- |
| 2 |
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) |
| 3 |
.\" |
| 4 |
.\" Standard preamble: |
| 5 |
.\" ======================================================================== |
| 6 |
.de Sp \" Vertical space (when we can't use .PP) |
| 7 |
.if t .sp .5v |
| 8 |
.if n .sp |
| 9 |
.. |
| 10 |
.de Vb \" Begin verbatim text |
| 11 |
.ft CW |
| 12 |
.nf |
| 13 |
.ne \\$1 |
| 14 |
.. |
| 15 |
.de Ve \" End verbatim text |
| 16 |
.ft R |
| 17 |
.fi |
| 18 |
.. |
| 19 |
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. |
| 20 |
.ie n \{\ |
| 21 |
. ds C` "" |
| 22 |
. ds C' "" |
| 23 |
'br\} |
| 24 |
.el\{\ |
| 25 |
. ds C` |
| 26 |
. ds C' |
| 27 |
'br\} |
| 28 |
.\" |
| 29 |
.\" Escape single quotes in literal strings from groff's Unicode transform. |
| 30 |
.ie \n(.g .ds Aq \(aq |
| 31 |
.el .ds Aq ' |
| 32 |
.\" |
| 33 |
.\" If the F register is >0, we'll generate index entries on stderr for |
| 34 |
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index |
| 35 |
.\" entries marked with X<> in POD. Of course, you'll have to process the |
| 36 |
.\" output yourself in some meaningful fashion. |
| 37 |
.\" |
| 38 |
.\" Avoid warning from groff about undefined register 'F'. |
| 39 |
.de IX |
| 40 |
.. |
| 41 |
.nr rF 0 |
| 42 |
.if \n(.g .if rF .nr rF 1 |
| 43 |
.if (\n(rF:(\n(.g==0)) \{\ |
| 44 |
. if \nF \{\ |
| 45 |
. de IX |
| 46 |
. tm Index:\\$1\t\\n%\t"\\$2" |
| 47 |
.. |
| 48 |
. if !\nF==2 \{\ |
| 49 |
. nr % 0 |
| 50 |
. nr F 2 |
| 51 |
. \} |
| 52 |
. \} |
| 53 |
.\} |
| 54 |
.rr rF |
| 55 |
.\" ======================================================================== |
| 56 |
.\" |
| 57 |
.IX Title "IPC::SharedMem 3perl" |
| 58 |
.TH IPC::SharedMem 3perl 2025-11-16 "perl v5.40.1" "Perl Programmers Reference Guide" |
| 59 |
.\" For nroff, turn off justification. Always turn off hyphenation; it makes |
| 60 |
.\" way too many mistakes in technical documents. |
| 61 |
.if n .ad l |
| 62 |
.nh |
| 63 |
.SH NAME |
| 64 |
IPC::SharedMem \- SysV Shared Memory IPC object class |
| 65 |
.SH SYNOPSIS |
| 66 |
.IX Header "SYNOPSIS" |
| 67 |
.Vb 2 |
| 68 |
\& use IPC::SysV qw(IPC_PRIVATE S_IRUSR S_IWUSR); |
| 69 |
\& use IPC::SharedMem; |
| 70 |
\& |
| 71 |
\& $shm = IPC::SharedMem\->new(IPC_PRIVATE, 8, S_IRWXU); |
| 72 |
\& |
| 73 |
\& $shm\->write(pack("S", 4711), 2, 2); |
| 74 |
\& |
| 75 |
\& $data = $shm\->read(0, 2); |
| 76 |
\& |
| 77 |
\& $ds = $shm\->stat; |
| 78 |
\& |
| 79 |
\& $shm\->remove; |
| 80 |
.Ve |
| 81 |
.SH DESCRIPTION |
| 82 |
.IX Header "DESCRIPTION" |
| 83 |
A class providing an object based interface to SysV IPC shared memory. |
| 84 |
.SH METHODS |
| 85 |
.IX Header "METHODS" |
| 86 |
.IP "new ( KEY , SIZE , FLAGS )" 4 |
| 87 |
.IX Item "new ( KEY , SIZE , FLAGS )" |
| 88 |
Creates a new shared memory segment of \f(CW\*(C`SIZE\*(C'\fR bytes size associated |
| 89 |
with \f(CW\*(C`KEY\*(C'\fR. A new segment is created if |
| 90 |
.RS 4 |
| 91 |
.IP \(bu 4 |
| 92 |
\&\f(CW\*(C`KEY\*(C'\fR is equal to \f(CW\*(C`IPC_PRIVATE\*(C'\fR |
| 93 |
.IP \(bu 4 |
| 94 |
\&\f(CW\*(C`KEY\*(C'\fR does not already have a shared memory segment associated |
| 95 |
with it, and \f(CW\*(C`\fR\f(CIFLAGS\fR\f(CW & IPC_CREAT\*(C'\fR is true. |
| 96 |
.RE |
| 97 |
.RS 4 |
| 98 |
.Sp |
| 99 |
On creation of a new shared memory segment \f(CW\*(C`FLAGS\*(C'\fR is used to |
| 100 |
set the permissions. Be careful not to set any flags that the |
| 101 |
Sys V IPC implementation does not allow: in some systems setting |
| 102 |
execute bits makes the operations fail. |
| 103 |
.RE |
| 104 |
.IP id 4 |
| 105 |
.IX Item "id" |
| 106 |
Returns the shared memory identifier. |
| 107 |
.IP "read ( POS, SIZE )" 4 |
| 108 |
.IX Item "read ( POS, SIZE )" |
| 109 |
Read \f(CW\*(C`SIZE\*(C'\fR bytes from the shared memory segment at \f(CW\*(C`POS\*(C'\fR. Returns |
| 110 |
the string read, or \f(CW\*(C`undef\*(C'\fR if there was an error. The return value |
| 111 |
becomes tainted. See shmread. |
| 112 |
.IP "write ( STRING, POS, SIZE )" 4 |
| 113 |
.IX Item "write ( STRING, POS, SIZE )" |
| 114 |
Write \f(CW\*(C`SIZE\*(C'\fR bytes to the shared memory segment at \f(CW\*(C`POS\*(C'\fR. Returns |
| 115 |
true if successful, or false if there is an error. See shmwrite. |
| 116 |
.IP remove 4 |
| 117 |
.IX Item "remove" |
| 118 |
Remove the shared memory segment from the system or mark it as |
| 119 |
removed as long as any processes are still attached to it. |
| 120 |
.IP is_removed 4 |
| 121 |
.IX Item "is_removed" |
| 122 |
Returns true if the shared memory segment has been removed or |
| 123 |
marked for removal. |
| 124 |
.IP stat 4 |
| 125 |
.IX Item "stat" |
| 126 |
Returns an object of type \f(CW\*(C`IPC::SharedMem::stat\*(C'\fR which is a sub-class |
| 127 |
of \f(CW\*(C`Class::Struct\*(C'\fR. It provides the following fields. For a description |
| 128 |
of these fields see you system documentation. |
| 129 |
.Sp |
| 130 |
.Vb 12 |
| 131 |
\& uid |
| 132 |
\& gid |
| 133 |
\& cuid |
| 134 |
\& cgid |
| 135 |
\& mode |
| 136 |
\& segsz |
| 137 |
\& lpid |
| 138 |
\& cpid |
| 139 |
\& nattch |
| 140 |
\& atime |
| 141 |
\& dtime |
| 142 |
\& ctime |
| 143 |
.Ve |
| 144 |
.IP "attach ( [FLAG] )" 4 |
| 145 |
.IX Item "attach ( [FLAG] )" |
| 146 |
Permanently attach to the shared memory segment. When a \f(CW\*(C`IPC::SharedMem\*(C'\fR |
| 147 |
object is attached, it will use memread and memwrite instead of |
| 148 |
shmread and shmwrite for accessing the shared memory segment. |
| 149 |
Returns true if successful, or false on error. See \fBshmat\fR\|(2). |
| 150 |
.IP detach 4 |
| 151 |
.IX Item "detach" |
| 152 |
Detach from the shared memory segment that previously has been attached |
| 153 |
to. Returns true if successful, or false on error. See \fBshmdt\fR\|(2). |
| 154 |
.IP addr 4 |
| 155 |
.IX Item "addr" |
| 156 |
Returns the address of the shared memory that has been attached to in a |
| 157 |
format suitable for use with \f(CWpack(\*(AqP\*(Aq)\fR. Returns \f(CW\*(C`undef\*(C'\fR if the shared |
| 158 |
memory has not been attached. |
| 159 |
.SH "SEE ALSO" |
| 160 |
.IX Header "SEE ALSO" |
| 161 |
IPC::SysV, Class::Struct |
| 162 |
.SH AUTHORS |
| 163 |
.IX Header "AUTHORS" |
| 164 |
Marcus Holland-Moritz <[email protected]> |
| 165 |
.SH COPYRIGHT |
| 166 |
.IX Header "COPYRIGHT" |
| 167 |
Version 2.x, Copyright (C) 2007\-2013, Marcus Holland-Moritz. |
| 168 |
.PP |
| 169 |
Version 1.x, Copyright (c) 1997, Graham Barr. |
| 170 |
.PP |
| 171 |
This program is free software; you can redistribute it and/or |
| 172 |
modify it under the same terms as Perl itself. |