reference/sem/functions/shm-attach.xml
395ea247cf337110d795979e14841617aa9cefa9
...
...
@@ -1,6 +1,6 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
-
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.shm-attach">
3
+
<refentry xml:id="function.shm-attach" xmlns="http://docbook.org/ns/docbook">
4
4
<refnamediv>
5
5
<refname>shm_attach</refname>
6
6
<refpurpose>Creates or open a shared memory segment</refpurpose>
...
...
@@ -9,24 +9,24 @@
9
9
<refsect1 role="description">
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
-
<type>resource</type><methodname>shm_attach</methodname>
12
+
<type class="union"><type>SysvSharedMemory</type><type>false</type></type><methodname>shm_attach</methodname>
13
13
<methodparam><type>int</type><parameter>key</parameter></methodparam>
14
-
<methodparam choice="opt"><type>int</type><parameter>memsize</parameter></methodparam>
15
-
<methodparam choice="opt"><type>int</type><parameter>perm</parameter><initializer>0666</initializer></methodparam>
14
+
<methodparam choice="opt"><type class="union"><type>int</type><type>null</type></type><parameter>size</parameter><initializer>&null;</initializer></methodparam>
15
+
<methodparam choice="opt"><type>int</type><parameter>permissions</parameter><initializer>0666</initializer></methodparam>
16
16
</methodsynopsis>
17
17
<para>
18
18
<function>shm_attach</function> returns an id that can be used to access
19
19
the System V shared memory with the given <parameter>key</parameter>, the
20
20
first call creates the shared memory segment with
21
-
<parameter>memsize</parameter> and the optional perm-bits
22
-
<parameter>perm</parameter>.
21
+
<parameter>size</parameter> and the optional perm-bits
22
+
<parameter>permissions</parameter>.
23
23
</para>
24
24
<para>
25
25
A second call to <function>shm_attach</function> for the same
26
-
<parameter>key</parameter> will return a different shared memory
27
-
identifier, but both identifiers access the same underlying
28
-
shared memory. <parameter>memsize</parameter> and
29
-
<parameter>perm</parameter> will be ignored.
26
+
<parameter>key</parameter> will return a different <classname>SysvSharedMemory</classname>
27
+
instance, but both instances access the same underlying
28
+
shared memory. <parameter>size</parameter> and
29
+
<parameter>permissions</parameter> will be ignored.
30
30
</para>
31
31
</refsect1>
32
32

...
...
@@ -43,7 +43,7 @@
43
43
</listitem>
44
44
</varlistentry>
45
45
<varlistentry>
46
-
<term><parameter>memsize</parameter></term>
46
+
<term><parameter>size</parameter></term>
47
47
<listitem>
48
48
<para>
49
49
The memory size. If not provided, default to the
...
...
@@ -53,7 +53,7 @@
53
53
</listitem>
54
54
</varlistentry>
55
55
<varlistentry>
56
-
<term><parameter>perm</parameter></term>
56
+
<term><parameter>permissions</parameter></term>
57
57
<listitem>
58
58
<para>
59
59
The optional permission bits. Default to 0666.
...
...
@@ -67,71 +67,37 @@
67
67
<refsect1 role="returnvalues">
68
68
&reftitle.returnvalues;
69
69
<para>
70
-
Returns a shared memory segment identifier.
70
+
Returns a <classname>SysvSharedMemory</classname> instance on success, &return.falseforfailure;.
71
71
</para>
72
72
</refsect1>
73
73

74
74
<refsect1 role="changelog">
75
75
&reftitle.changelog;
76
-
<para>
77
-
<informaltable>
78
-
<tgroup cols="2">
79
-
<thead>
80
-
<row>
81
-
<entry>&Version;</entry>
82
-
<entry>&Description;</entry>
83
-
</row>
84
-
</thead>
85
-
<tbody>
86
-
<row>
87
-
<entry>5.3.0</entry>
88
-
<entry>
89
-
This function now returns a &resource; instead of an
90
-
<link linkend="language.types.integer">integer</link>.
91
-
</entry>
92
-
</row>
93
-
</tbody>
94
-
</tgroup>
95
-
</informaltable>
96
-
</para>
97
-
</refsect1>
98
-

99
-
<refsect1 role="notes">
100
-
&reftitle.notes;
101
-
<note>
102
-
<para>
103
-
This function used to return an integer value prior to
104
-
PHP 5.3.0. To achieve the same value in a portable manner, the
105
-
return value can be cast to an integer like:
106
-
</para>
107
-
<para>
108
-
<example>
109
-
<programlisting role="php">
110
-
<![CDATA[
111
-
<?php
112
-
// Create a temporary file and return its path
113
-
$tmp = tempnam('/tmp', 'PHP');
114
-

115
-
// Get the file token key
116
-
$key = ftok($tmp, 'a');
117
-

118
-
// Attach the SHM resource, notice the cast afterwards
119
-
$id = shm_attach($key);
120
-

121
-
if ($id === false) {
122
-
die('Unable to create the shared memory segment');
123
-
}
124
-

125
-
// Cast to integer, since prior to PHP 5.3.0 the resource id
126
-
// is returned which can be exposed when casting a resource
127
-
// to an integer
128
-
$id = (integer) $id;
129
-
?>
130
-
]]>
131
-
</programlisting>
132
-
</example>
133
-
</para>
134
-
</note>
76
+
<informaltable>
77
+
<tgroup cols="2">
78
+
<thead>
79
+
<row>
80
+
<entry>&Version;</entry>
81
+
<entry>&Description;</entry>
82
+
</row>
83
+
</thead>
84
+
<tbody>
85
+
<row>
86
+
<entry>8.0.0</entry>
87
+
<entry>
88
+
On success, this function returns an <classname>SysvSharedMemory</classname> instance now;
89
+
previously, a <type>resource</type> was returned.
90
+
</entry>
91
+
</row>
92
+
<row>
93
+
<entry>8.0.0</entry>
94
+
<entry>
95
+
<parameter>size</parameter> is nullable now.
96
+
</entry>
97
+
</row>
98
+
</tbody>
99
+
</tgroup>
100
+
</informaltable>
135
101
</refsect1>
136
102

137
103
<refsect1 role="seealso">
...
...
@@ -145,7 +111,6 @@ $id = (integer) $id;
145
111
</refsect1>
146
112

147
113
</refentry>
148
-

149
114
<!-- Keep this comment at the end of the file
150
115
Local variables:
151
116
mode: sgml
152
117