1
<?xml version="1.0" encoding="ISO8859-1"?>
5
$Id: ipc.xml,v 1.2 2004/09/13 19:27:49 michael Exp $
6
This file is part of the FPC documentation.
7
Copyright (C) 1997, by Michael Van Canneyt
9
The FPC documentation is free text; you can redistribute it and/or
10
modify it under the terms of the GNU Library General Public License as
11
published by the Free Software Foundation; either version 2 of the
12
License, or (at your option) any later version.
14
The FPC Documentation is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
Library General Public License for more details.
19
You should have received a copy of the GNU Library General Public
20
License along with the FPC documentation; see the file COPYING.LIB. If not,
21
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22
Boston, MA 02111-1307, USA.
26
<short>Unix Inter Process Communication functionality.</short>
27
<!-- \FPCexampledir{ipcex} -->
30
This document describes the IPC unit for Free Pascal. It was written for
31
linux by Michael Van Canneyt. It gives all the functionality of system V
32
Inter-Process Communication: shared memory, semaphores and messages.
33
It works only on the linux operating system.
36
Many constants here are provided for completeness only, and should under
37
normal circumstances not be used by the programmer.
41
<element name="IPCerror">
42
<short>Last IPC error code</short>
44
The <var>IPCerror</var> variable is used to report errors, by all calls.
48
<element name="IPC_CREAT">
49
<short>Create if key is nonexistent</short>
52
<element name="IPC_EXCL">
53
<short>fail if key exists</short>
56
<element name="IPC_NOWAIT">
57
<short>return error on wait</short>
60
<element name="IPC_RMID">
61
<short>Remove resource</short>
63
<element name="IPC_SET">
64
<short>set ipc_perm options</short>
66
<element name="IPC_STAT">
67
<short>get ipc_perm options</short>
69
<element name="IPC_INFO">
70
<short>For ipcs call</short>
73
<element name="MSG_NOERROR">
74
<short>Internal Message control code. Do not use</short>
76
<element name="MSG_EXCEPT">
77
<short>Internal Message control code. Do not use</short>
79
<element name="MSGMNI">
80
<short>Internal Message control code. Do not use</short>
82
<element name="MSGMAX">
83
<short>Internal Message control code. Do not use</short>
85
<element name="MSGMNB">
86
<short>Internal Message control code. Do not use</short>
89
<element name="SEM_UNDO">
90
<short>Constant for use in <link id="semop"/></short>
92
<element name="GETPID">
93
<short>Constant for use in <link id="semop"/></short>
95
<element name="GETVAL">
96
<short>Constant for use in <link id="semop"/></short>
98
<element name="GETALL">
99
<short>Constant for use in <link id="semop"/></short>
101
<element name="GETNCNT">
102
<short>Constant for use in <link id="semop"/></short>
104
<element name="GETZCNT">
105
<short>Constant for use in <link id="semop"/></short>
107
<element name="SETVAL">
108
<short>Constant for use in <link id="semop"/></short>
110
<element name="SETALL">
111
<short>Constant for use in <link id="semop"/></short>
114
<element name="SEMMNI">
115
<short>Internal semaphore system constant. Do not use.</short>
117
<element name="SEMMSL">
118
<short>Internal semaphore system constant. Do not use.</short>
120
<element name="SEMMNS">
121
<short>Internal semaphore system constant. Do not use.</short>
123
<element name="SEMOPM">
124
<short>Internal semaphore system constant. Do not use.</short>
126
<element name="SEMVMX">
127
<short>Internal semaphore system constant. Do not use.</short>
130
<element name="SHM_R">
131
<short>This constant is used in the <link id="shmctl"/> call.</short>
133
<element name="SHM_W">
134
<short>This constant is used in the <link id="shmctl"/> call.</short>
136
<element name="SHM_RDONLY">
137
<short>This constant is used in the <link id="shmctl"/> call.</short>
139
<element name="SHM_RND">
140
<short>This constant is used in the <link id="shmctl"/> call.</short>
142
<element name="SHM_REMAP">
143
<short>This constant is used in the <link id="shmctl"/> call.</short>
145
<element name="SHM_LOCK">
146
<short>This constant is used in the <link id="shmctl"/> call.</short>
148
<element name="SHM_UNLOCK">
149
<short>This constant is used in the <link id="shmctl"/> call.</short>
152
<element name="BaseUnix">
153
<short>Some base types</short>
156
<element name="key_t">
157
<short>Alias for <link id="TKey"/> type</short>
160
<element name="TIPC_Perm.mode">
161
<short>Creation Mode</short>
164
<element name="TSHMinfo.shmmni">
168
<element name="msglen_t">
169
<short>Message length type</short>
172
<element name="msgqnum_t">
173
<short>Message queue number type</short>
176
<element name="PMSG">
177
<short>Pointer to <link id="TMSG"/> record</short>
180
<element name="PMSQid_ds">
181
<short>Pointer to <link id="TMSQid_ds"/></short>
184
<element name="PMSGbuf">
185
<short>Pointer to <link id="TMsgBuf"/> rcord</short>
188
<element name="SEM_GETPID">
189
<short>Semaphore operation: Get process ID of last operation.</short>
192
<element name="SEM_GETVAL">
193
<short>Semaphore operation: Get current value of semaphore</short>
196
<element name="SEM_GETALL">
197
<short>Semaphore operation: Get all semaphore values</short>
200
<element name="SEM_GETNCNT">
201
<short>Semaphore operation: Get number of processes waiting for resource.</short>
204
<element name="SEM_GETZCNT">
205
<short>Semaphore operation: Get number of processes waiting for semaphores to reach zero </short>
208
<element name="SEM_SETVAL">
209
<short>Semaphore operation: Set semaphore value</short>
212
<element name="SEM_SETALL">
213
<short>Semaphore operation: Set all semaphore values</short>
217
<element name="SEM_SEMMNI">
218
<short>Semaphore operation: ?</short>
222
<element name="SEM_SEMMSL">
223
<short>Semaphore operation: ?</short>
227
<element name="SEM_SEMMNS">
228
<short>Semaphore operation: ?</short>
231
<element name="SEM_SEMOPM">
232
<short>Semaphore operation: ?</short>
236
<element name="SEM_SEMVMX">
237
<short>Semaphore operation: ?</short>
241
<element name="TSEMid_ds.sem_nsems">
242
<short>Number of semaphores</short>
245
<element name="PULong">
246
<short>Pointer to cardinal type.</short>
248
<element name="PWord">
249
<short>Pointer to word type.</short>
252
<element name="TKey">
253
<short>Type returned by the <link id="ftok"/> key generating
257
<element name="TIPC_Perm">
258
<short>Record used in all IPC systems to specify the permissions.</short>
260
<var>TIPC_Perm</var> is used in all IPC systems to specify the permissions.
261
It should never be used directly.
264
<element name="TIPC_Perm.Key">
265
<short>key used to create resource</short>
267
<element name="TIPC_Perm.uid">
268
<short>Owner user ID</short>
270
<element name="TIPC_Perm.gid">
271
<short>Owner group id</short>
273
<element name="TIPC_Perm.cuid">
274
<short>Creator user ID</short>
276
<element name="TIPC_Perm.cgid">
277
<short>Creator group ID</short>
279
<element name="TIPC_Perm.seq">
283
<element name="PIPC_Perm">
284
<short>Pointer to <link id="TIPC_Perm"/> record.</short>
287
<element name="TSHMid_ds">
288
<short>Record used in the <link id="shmctl"/> call to set or retrieve settings for shared memory.</short>
290
<element name="PSHMid_DS">
291
<short>Pointer to <link id="TSHMid_ds"/> record.</short>
293
<element name="TSHMid_ds.shm_perm">
294
<short>Permissions</short>
296
<element name="TSHMid_ds.shm_segsz">
297
<short>Segment size</short>
299
<element name="TSHMid_ds.shm_atime">
300
<short>Last access time</short>
302
<element name="TSHMid_ds.shm_dtime">
303
<short>Last detach time</short>
305
<element name="TSHMid_ds.shm_ctime">
306
<short>Create time</short>
308
<element name="TSHMid_ds.shm_cpid">
309
<short>Creator PID</short>
311
<element name="TSHMid_ds.shm_lpid">
312
<short>Last operation PID</short>
314
<element name="TSHMid_ds.shm_nattch">
315
<short>Number of attachments</short>
317
<element name="TSHMid_ds.shm_npages">
318
<short>Number of pages</short>
320
<element name="TSHMid_ds.shm_pages">
323
<element name="TSHMid_ds.attaches">
327
<element name="TSHMinfo">
328
<short>Record used by the shared memory system, Do not use directly.</short>
330
<element name="TSHMinfo.shmmax" skip="1"/>
331
<element name="TSHMinfo.shmmin" skip="1"/>
332
<element name="TSHMinfo.smmni" skip="1"/>
333
<element name="TSHMinfo.shmseg" skip="1"/>
334
<element name="TSHMinfo.shmall" skip="1"/>
335
<element name="PSHMinfo" skip="1"/>
337
<element name="TMSG">
338
<short>Record used in the handling of message queues. Do not use directly.</short>
340
<element name="TMSG.msg_next" skip="1"/>
341
<element name="TMSG.msg_type" skip="1"/>
342
<element name="TMSG.msg_spot" skip="1"/>
343
<element name="TMSG.msg_stime" skip="1"/>
344
<element name="TMSG.msg_ts" skip="1"/>
346
<element name="TMSQid_ds">
347
<short>Record returned by the <link id="msgctl"/> call, contains all data about a message queue.</short>
349
This record should never be used directly, it is an internal kernel record.
350
It's fields may change at any time.
354
<element name="TMSQid_ds.msg_perm">
355
<short>Queue permissions</short>
357
<element name="TMSQid_ds.msg_first">
358
<short>Pointer to first message</short>
360
<element name="TMSQid_ds.msg_last">
361
<short>Pointer to last message</short>
363
<element name="TMSQid_ds.msg_stime">
364
<short>Last send time</short>
366
<element name="TMSQid_ds.msg_rtime">
367
<short>Last receive time</short>
369
<element name="TMSQid_ds.msg_ctime">
370
<short>Last control time</short>
372
<element name="TMSQid_ds.wwait">
375
<element name="TMSQid_ds.rwait">
378
<element name="TMSQid_ds.msg_cbytes">
381
<element name="TMSQid_ds.msg_qnum">
384
<element name="TMSQid_ds.msg_qbytes">
387
<element name="TMSQid_ds.msg_lspid">
390
<element name="TMSQid_ds.msg_lrpid">
394
<element name="TMSGbuf">
395
<short>Generic message data record</short>
397
The <var>TMSGbuf</var> record is a record containing the data of a record. you
398
should never use this record directly, instead you should make your own
399
record that follows the structure of the <var>TMSGbuf</var> record, but that has
400
a size that is big enough to accomodate your messages. The <var>mtype</var> field
401
should always be present, and should always be filled.
404
<element name="TMSGbuf.mtype">
405
<short>Message type</short>
407
<element name="TMSGbuf.mtext">
408
<short>Message data</short>
411
<element name="TMSGinfo" skip="1">
412
<short>Internal message system record. Do not use directly.</short>
414
<element name="TMSGinfo.msgpool" skip="1"/>
415
<element name="TMSGinfo.msgmap" skip="1"/>
416
<element name="TMSGinfo.msgmax" skip="1"/>
417
<element name="TMSGinfo.msgmax" skip="1"/>
418
<element name="TMSGinfo.msgmnb" skip="1"/>
419
<element name="TMSGinfo.msgmni" skip="1"/>
420
<element name="TMSGinfo.msgssz" skip="1"/>
421
<element name="TMSGinfo.msgtql" skip="1"/>
422
<element name="TMSGinfo.msgseg" skip="1"/>
424
<element name="PMSGinfo" skip="1">
425
<short>Pointer to <link id="TMSGinfo"/> record</short>
428
<element name="TSEMid_ds">
429
<short>Structure returned by the <link id="semctl"/> call, contains all data of a semahore</short>
432
<element name="PSEMid_ds">
433
<short>Pointer to <link id="TSEMid_ds"/> record.</short>
436
<element name="TSEMid_ds.sem_perm">
437
<short>IPC permissions</short>
440
<element name="TSEMid_ds.sem_otime">
441
<short>Last operation time</short>
444
<element name="TSEMid_ds.sem_ctime">
445
<short>Create time</short>
448
<element name="TSEMid_ds.sem_base">
449
<short>Internal data. Do not use</short>
452
<element name="TSEMid_ds.sem_pending">
453
<short>Internal data. Do not use</short>
455
<element name="TSEMid_ds.sem_pending_last">
456
<short>Internal data. Do not use</short>
458
<element name="TSEMid_ds.undo">
459
<short>Internal data. Do not use</short>
461
<element name="TSEMid_ds.nsems">
462
<short>Internal data. Do not use</short>
465
<element name="TSEMbuf">
466
<short>Record used in <link id="semop"/> call.</short>
468
The <var>TSEMbuf</var> record is used in the <link id="semop"/> call, and is
469
used to specify which operations you want to do.
473
<element name="PSEMbuf">
474
<short>Pointer to <link id="TSembuf"/> record.</short>
476
<element name="TSEMbuf.sem_num">
477
<short>Number of the semaphore to perform operation on.</short>
479
<element name="TSEMbuf.sem_op">
480
<short>Operation to perform on semaphore</short>
482
<element name="TSEMbuf.sem_flg">
483
<short>Flags for operation.</short>
486
<element name="TSEMinfo" skip="1">
487
<short>Internal semaphore system record. Do not use.</short>
489
<element name="TSEMinfo.semmap" skip="1"/>
490
<element name="TSEMinfo.semmni" skip="1"/>
491
<element name="TSEMinfo.semmns" skip="1"/>
492
<element name="TSEMinfo.semmnu" skip="1"/>
493
<element name="TSEMinfo.semmsl" skip="1"/>
494
<element name="TSEMinfo.semopm" skip="1"/>
495
<element name="TSEMinfo.semume" skip="1"/>
496
<element name="TSEMinfo.semusz" skip="1"/>
497
<element name="TSEMinfo.semvmx" skip="1"/>
498
<element name="TSEMinfo.semaem" skip="1"/>
500
<element name="PSEMinfo">
501
<short>Pointer to <link id="TSEMinfo"/> record.</short>
504
<element name="TSEMun">
505
<short>Record used in <link id="semctl"/> call.</short>
507
<element name="PSEMun">
508
<short>Pointer to <link id="TSEMun"/> record</short>
511
<element name="ftok">
512
<short>Create token from filename</short>
515
<var>ftok</var> returns a key that can be used in a <link id="semget"/>
517
or <link id="msgget"/> call to access a new or existing IPC resource.
520
<var>Path</var> is the name of a file in the file system, <var>ID</var> is a
521
character of your choice. The ftok call does the same as it's C couterpart,
522
so a pascal program and a C program will access the same resource if
523
they use the same <var>Path</var> and <var>ID</var>
526
For an example, see <link id="msgctl"/>, <link id="semctl"/> or <link id="shmctl"/>.
530
<var>ftok</var> returns -1 if the file in <var>Path</var> doesn't exist.
540
<element name="msgget">
541
<short>Return message queue ID, possibly creating the queue</short>
544
<var>msgget</var> returns the ID of the message queue described by <var>key</var>.
545
Depending on the flags in <var>msgflg</var>, a new queue is created.
548
<var>msgflg</var> can have one or more of the following values (combined by ORs):
551
<dt>IPC_CREAT</dt><dd> The queue is created if it doesn't already exist.</dd>
552
<dt>IPC_EXCL</dt><dd> If used in combination with <var>IPC_CREAT</var>, causes the
553
call to fail if the queue already exists. It cannot be used by itself.
557
Optionally, the flags can be <var>OR</var>ed with a permission mode, which is the
558
same mode that can be used in the file system.
561
For an example, see <link id="msgctl"/>.
565
On error, -1 is returned, and <var>IPCError</var> is set.
576
<element name="msgsnd">
577
<short>Send a message to the messague queue</short>
580
<var>msgsend</var> sends a message to a message queue with ID <var>msqid</var>.
581
<var>msgp</var> is a pointer to a message buffer, that should be based on the
582
<var>TMsgBuf</var> type. <var>msgsiz</var> is the size of the message (NOT of the
583
message buffer record !)
586
The <var>msgflg</var> can have a combination of the following values (ORed
590
<dt>0</dt><dd>No special meaning. The message will be written to the queue.
591
If the queue is full, then the process is blocked.</dd>
592
<dt>IPC_NOWAIT</dt><dd> If the queue is full, then no message is written,
593
and the call returns immediatly.
597
The function returns <var>True</var> if the message was sent successfully,
598
<var>False</var> otherwise.
601
For an example, see <link id="msgctl"/>.
605
In case of error, the call returns <var>False</var>, and <var>IPCerror</var> is set.
615
<element name="msgrcv">
616
<short>Retrieve a message from the queue</short>
619
<var>msgrcv</var> retrieves a message of type <var>msgtyp</var> from the message
620
queue with ID <var>msqid</var>. <var>msgtyp</var> corresponds to the <var>mtype</var>
621
field of the <var>TMSGbuf</var> record. The message is stored in the <var>MSGbuf</var>
622
structure pointed to by <var>msgp</var>.
625
The <var>msgflg</var> parameter can be used to control the behaviour of the
626
<var>msgrcv</var> call. It consists of an ORed combination of the following
630
<dt>0</dt><dd> No special meaning.</dd>
631
<dt>IPC_NOWAIT</dt><dd>if no messages are available, then the call returns
632
immediatly, with the <var>ENOMSG</var> error.</dd>
633
<dt>MSG_NOERROR</dt><dd> If the message size is wrong (too large),
634
no error is generated, instead the message is truncated.
635
Normally, in such cases, the call returns an error (E2BIG)
639
The function returns <var>True</var> if the message was received correctly,
640
<var>False</var> otherwise.
643
For an example, see <link id="msgctl"/>.
647
In case of error, <var>False</var> is returned, and <var>IPCerror</var> is set.
657
<element name="msgctl">
658
<short>Perform various operations on a message queue</short>
661
<var>msgctl</var> performs various operations on the message queue with id
662
<var>ID</var>. Which operation is performed, depends on the <var>cmd</var>
663
parameter, which can have one of the following values:
666
<dt>IPC_STAT</dt><dd> In this case, the <var>msgctl</var> call fills the
667
<var>TMSQid_ds</var> structure with information about the message queue.
669
<dt>IPC_SET</dt><dd> in this case, the <var>msgctl</var> call sets the permissions
670
of the queue as specified in the <var>ipc_perm</var> record inside <var>buf</var>.
671
</dd><dt>IPC_RMID</dt><dd> If this is specified, the message queue will be removed
676
<var>buf</var> contains the data that are needed by the call. It can be
677
<var>Nil</var> in case the message queue should be removed.
680
The function returns <var>True</var> if successfull, <var>False</var> otherwise.
684
On error, <var>False</var> is returned, and <var>IPCerror</var> is set accordingly.
691
<example file="ipcex/msgtool"/>
695
<element name="semget">
696
<short>Return the ID of a semaphore set, possibly creating the set</short>
699
<var>msgget</var> returns the ID of the semaphore set described by <var>key</var>.
700
Depending on the flags in <var>semflg</var>, a new queue is created.
703
<var>semflg</var> can have one or more of the following values (combined by ORs):
706
<dt>IPC_CREAT</dt><dd> The queue is created if it doesn't already exist.</dd>
707
<dt>IPC_EXCL</dt><dd> If used in combination with <var>IPC_CREAT</var>, causes the
708
call to fail if the set already exists. It cannot be used by itself.</dd>
711
Optionally, the flags can be <var>OR</var>ed with a permission mode, which is the
712
same mode that can be used in the file system.
715
if a new set of semaphores is created, then there will be <var>nsems</var>
720
On error, -1 is returned, and <var>IPCError</var> is set.
729
<element name="semop">
730
<short>Perform semaphore operation.</short>
733
<var>semop</var> performs a set of operations on a message queue.
734
<var>sops</var> points to an array of type <var>TSEMbuf</var>. The array should
735
contain <var>nsops</var> elements.
738
The fields of the <link id="TSEMbuf"/> structure
747
should be filled as follows:
750
<dt>sem_num</dt><dd> The number of the semaphore in the set on which the
751
operation must be performed.</dd>
753
The operation to be performed. The operation depends on the
754
sign of <var>sem_op</var>:
755
A positive number is simply added to the current value of the
756
semaphore. If 0 (zero) is specified, then the process is suspended until the
757
specified semaphore reaches zero. If a negative number is specified, it is substracted from the
758
current value of the semaphore. If the value would become negative
759
then the process is suspended until the value becomes big enough, unless
760
<var>IPC_NOWAIT</var> is specified in the <var>sem_flg</var>.
763
<dd> Optional flags: if <var>IPC_NOWAIT</var> is specified, then the
764
calling process will never be suspended.
768
The function returns <var>True</var> if the operations were successful,
769
<var>False</var> otherwise.
773
In case of error, <var>False</var> is returned, and <var>IPCerror</var> is set.
781
<element name="semctl">
782
<short>Perform various control operations on a semaphore set</short>
785
<var>semctl</var> performs various operations on the semaphore <var>semnum</var> w
786
ith semaphore set id <var>ID</var>.
789
The <var>arg</var> parameter supplies the data needed for each call. This is
790
a variant record that should be filled differently, according to the
797
0 : ( val : longint );
798
1 : ( buf : PSEMid_ds );
800
3 : ( padbuf : PSeminfo );
801
4 : ( padpad : pointer );
805
Which operation is performed, depends on the <var>cmd</var>
806
parameter, which can have one of the following values:
810
<dd> In this case, the arg record should have it's <var>buf</var>
811
field set to the address of a <var>TSEMid_ds</var> record.
812
The <var>semctl</var> call fills this <var>TSEMid_ds</var> structure with information
813
about the semaphore set.
816
<dd> In this case, the <var>arg</var> record should have it's <var>buf</var>
817
field set to the address of a <var>TSEMid_ds</var> record.
818
The <var>semctl</var> call sets the permissions of the queue as specified in
819
the <var>ipc_perm</var> record.
822
<dd> If this is specified, the semaphore set is removed from
826
<dd> In this case, the <var>arr</var> field of <var>arg</var> should point
827
to a memory area where the values of the semaphores will be stored.
828
The size of this memory area is \var{SizeOf(Word)* Number of semaphores
830
This call will then fill the memory array with all the values of the
834
<dd> This will fill the <var>val</var> field of the <var>arg</var> union
835
with the number of processes waiting for resources.
838
<dd> <var>semctl</var> returns the process ID of the process that
839
performed the last <link id="semop"/> call.
842
<dd> <var>semctl</var> returns the value of the semaphore with number
846
<dd> <var>semctl</var> returns the number of processes waiting for
847
semaphores that reach value zero.
850
<dd> In this case, the <var>arr</var> field of <var>arg</var> should point
851
to a memory area where the values of the semaphores will be retrieved from.
852
The size of this memory area is \var{SizeOf(Word)* Number of semaphores
854
This call will then set the values of the semaphores from the memory array.
857
<dd> This will set the value of semaphore <var>semnum</var> to the value
858
in the <var>val</var> field of the <var>arg</var> parameter.
862
The function returns -1 on error.
866
The function returns -1 on error, and <var>IPCerror</var> is set accordingly.
872
<example file="ipcex/semtool"/>
876
<element name="shmget">
877
<short>Return the ID of a shared memory block, possibly creating it</short>
880
<var>shmget</var> returns the ID of a shared memory block, described by <var>key</var>.
881
Depending on the flags in <var>flag</var>, a new memory block is created.
884
<var>flag</var> can have one or more of the following values (combined by ORs):
888
<dd> The queue is created if it doesn't already exist.
891
<dd> If used in combination with <var>IPC_CREAT</var>, causes the
892
call to fail if the queue already exists. It cannot be used by itself.
896
Optionally, the flags can be <var>OR</var>ed with a permission mode, which is the
897
same mode that can be used in the file system.
900
if a new memory block is created, then it will have size <var>Size</var>
905
On error, -1 is returned, and <var>IPCError</var> is set.
911
<element name="shmat">
912
<short>Attach a shared memory block.</short>
915
<var>shmat</var> attaches a shared memory block with identified <var>shmid</var>
916
to the current process. The function returns a pointer to the shared memory
920
If <var>shmaddr</var> is <var>Nil</var>, then the system chooses a free unmapped
921
memory region, as high up in memory space as possible.
924
If <var>shmaddr</var> is non-nil, and <var>SHM_RND</var> is in <var>shmflg</var>, then
925
the returned address is <var>shmaddr</var>, rounded down to <var>SHMLBA</var>.
926
If <var>SHM_RND</var> is not specified, then <var>shmaddr</var> must be a
927
page-aligned address.
930
The parameter <var>shmflg</var> can be used to control the behaviour of the
931
<var>shmat</var> call. It consists of a ORed combination of the following
935
<dt>SHM_RND</dt> <dd> The suggested address in <var>shmaddr</var> is rounded down to
938
<dt>SHM_RDONLY</dt> <dd> the shared memory is attached for read access only.
939
Otherwise the memory is attached for read-write. The process then needs
940
read-write permissions to access the shared memory.
944
For an example, see <link id="shmctl"/>.
948
If an error occurs, -1 is returned, and <var>IPCerror</var> is set.
958
<element name="shmdt">
959
<short>Detach shared memory block.</short>
962
<var>shmdt</var> detaches the shared memory at address <var>shmaddr</var>. This shared
963
memory block is unavailable to the current process, until it is attached
964
again by a call to <link id="shmat"/>.
967
The function returns <var>True</var> if the memory block was detached
968
successfully, <var>False</var> otherwise.
972
On error, False is returned, and IPCerror is set.
981
<element name="shmctl">
982
<short>Perform control operations on a shared memory block.</short>
985
<var>shmctl</var> performs various operations on the shared memory block
986
identified by identifier <var>shmid</var>.
989
The <var>buf</var> parameter points to a <var>TSHMid_ds</var> record. The
990
<var>cmd</var> parameter is used to pass which operation is to be performed.
991
It can have one of the following values :
994
<dt>IPC_STAT</dt><dd> <var>shmctl</var> fills the <var>TSHMid_ds</var> record that
995
<var>buf</var> points to with the available information about the shared memory
997
<dt>IPC_SET</dt><dd> applies the values in the <var>ipc_perm</var> record that
998
<var>buf</var> points to, to the shared memory block.</dd>
999
<dt>IPC_RMID</dt><dd> the shared memory block is destroyed (after all processes
1000
to which the block is attached, have detached from it).</dd>
1003
If successful, the function returns <var>True</var>, <var>False</var> otherwise.
1007
If an error occurs, the function returns <var>False</var>, and <var>IPCerror</var>
1015
<example file="ipcex/shmtool"/>
1020
</fpdoc-descriptions>