1SHMGET(3P)                 POSIX Programmer's Manual                SHMGET(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       shmget - get an XSI shared memory segment
13

SYNOPSIS

15       #include <sys/shm.h>
16
17       int shmget(key_t key, size_t size, int shmflg);
18
19

DESCRIPTION

21       The shmget() function operates on XSI shared memory (see the Base Defi‐
22       nitions  volume  of  IEEE Std 1003.1-2001, Section 3.340, Shared Memory
23       Object). It is unspecified whether this function interoperates with the
24       realtime interprocess communication facilities defined in Realtime .
25
26       The shmget() function shall return the shared memory identifier associ‐
27       ated with key.
28
29       A shared memory identifier, associated data structure, and shared  mem‐
30       ory  segment  of  at least size bytes (see <sys/shm.h>) are created for
31       key if one of the following is true:
32
33        * The argument key is equal to IPC_PRIVATE.
34
35        * The argument key does not already have a  shared  memory  identifier
36          associated with it and (shmflg &IPC_CREAT) is non-zero.
37
38       Upon creation, the data structure associated with the new shared memory
39       identifier shall be initialized as follows:
40
41        * The  values  of  shm_perm.cuid,  shm_perm.uid,  shm_perm.cgid,   and
42          shm_perm.gid  are  set  equal to the effective user ID and effective
43          group ID, respectively, of the calling process.
44
45        * The low-order nine bits of shm_perm.mode are set equal to  the  low-
46          order nine bits of shmflg.
47
48        * The value of shm_segsz is set equal to the value of size.
49
50        * The values of shm_lpid, shm_nattch, shm_atime, and shm_dtime are set
51          equal to 0.
52
53        * The value of shm_ctime is set equal to the current time.
54
55       When the shared memory segment is created, it shall be initialized with
56       all zero values.
57

RETURN VALUE

59       Upon  successful completion, shmget() shall return a non-negative inte‐
60       ger, namely a shared memory identifier; otherwise, it shall  return  -1
61       and set errno to indicate the error.
62

ERRORS

64       The shmget() function shall fail if:
65
66       EACCES A  shared memory identifier exists for key but operation permis‐
67              sion as specified by the low-order nine bits of shmflg would not
68              be granted; see XSI Interprocess Communication .
69
70       EEXIST A shared memory identifier exists for the argument key but (shm‐
71              flg &IPC_CREAT) &&(shmflg &IPC_EXCL) is non-zero.
72
73       EINVAL A shared memory segment is to be created and the value  of  size
74              is less than the system-imposed minimum or greater than the sys‐
75              tem-imposed maximum.
76
77       EINVAL No shared memory segment is to be created and  a  shared  memory
78              segment  exists  for  key but the size of the segment associated
79              with it is less than size and size is not 0.
80
81       ENOENT A shared memory identifier does not exist for the  argument  key
82              and (shmflg &IPC_CREAT) is 0.
83
84       ENOMEM A  shared memory identifier and associated shared memory segment
85              shall be created, but the amount of available physical memory is
86              not sufficient to fill the request.
87
88       ENOSPC A  shared  memory  identifier  is to be created, but the system-
89              imposed limit on the maximum number  of  allowed  shared  memory
90              identifiers system-wide would be exceeded.
91
92
93       The following sections are informative.
94

EXAMPLES

96       None.
97

APPLICATION USAGE

99       The  POSIX Realtime Extension defines alternative interfaces for inter‐
100       process communication. Application  developers  who  need  to  use  IPC
101       should design their applications so that modules using the IPC routines
102       described in XSI Interprocess Communication can be easily  modified  to
103       use the alternative interfaces.
104

RATIONALE

106       None.
107

FUTURE DIRECTIONS

109       None.
110

SEE ALSO

112       XSI  Interprocess  Communication, Realtime, shmat(), shmctl(), shmdt(),
113       shm_open(),   shm_unlink(),   the   Base    Definitions    volume    of
114       IEEE Std 1003.1-2001, <sys/shm.h>
115
117       Portions  of  this text are reprinted and reproduced in electronic form
118       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
119       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
120       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
121       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
122       event of any discrepancy between this version and the original IEEE and
123       The  Open Group Standard, the original IEEE and The Open Group Standard
124       is the referee document. The original Standard can be  obtained  online
125       at http://www.opengroup.org/unix/online.html .
126
127
128
129IEEE/The Open Group                  2003                           SHMGET(3P)
Impressum