logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

shmget.3p (5346B)


  1. '\" et
  2. .TH SHMGET "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. shmget
  12. \(em get an XSI shared memory segment
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <sys/shm.h>
  17. .P
  18. int shmget(key_t \fIkey\fP, size_t \fIsize\fP, int \fIshmflg\fP);
  19. .fi
  20. .SH DESCRIPTION
  21. The
  22. \fIshmget\fR()
  23. function operates on XSI shared memory (see the Base Definitions volume of POSIX.1\(hy2017,
  24. .IR "Section 3.346" ", " "Shared Memory Object").
  25. It is unspecified whether this function interoperates with the
  26. realtime interprocess communication facilities defined in
  27. .IR "Section 2.8" ", " "Realtime".
  28. .P
  29. The
  30. \fIshmget\fR()
  31. function shall return the shared memory identifier associated with
  32. .IR key .
  33. .P
  34. A shared memory identifier, associated data structure, and shared
  35. memory segment of at least
  36. .IR size
  37. bytes (see
  38. .IR <sys/shm.h> )
  39. are created for
  40. .IR key
  41. if one of the following is true:
  42. .IP " *" 4
  43. The argument
  44. .IR key
  45. is equal to IPC_PRIVATE.
  46. .IP " *" 4
  47. The argument
  48. .IR key
  49. does not already have a shared memory identifier associated with it and
  50. (\fIshmflg\fP &IPC_CREAT) is non-zero.
  51. .P
  52. Upon creation, the data structure associated with the new shared memory
  53. identifier shall be initialized as follows:
  54. .IP " *" 4
  55. The values of
  56. .IR shm_perm.cuid ,
  57. .IR shm_perm.uid ,
  58. .IR shm_perm.cgid ,
  59. and
  60. .IR shm_perm.gid
  61. are set to the effective user ID and effective group ID,
  62. respectively, of the calling process.
  63. .IP " *" 4
  64. The low-order nine bits of
  65. .IR shm_perm.mode
  66. are set to the low-order nine bits of
  67. .IR shmflg .
  68. .IP " *" 4
  69. The value of
  70. .IR shm_segsz
  71. is set to the value of
  72. .IR size .
  73. .IP " *" 4
  74. The values of
  75. .IR shm_lpid ,
  76. .IR shm_nattch ,
  77. .IR shm_atime ,
  78. and
  79. .IR shm_dtime
  80. are set to 0.
  81. .IP " *" 4
  82. The value of
  83. .IR shm_ctime
  84. is set to the current time, as described in
  85. .IR "Section 2.7.1" ", " "IPC General Description".
  86. .P
  87. When the shared memory segment is created, it shall be initialized
  88. with all zero values.
  89. .SH "RETURN VALUE"
  90. Upon successful completion,
  91. \fIshmget\fR()
  92. shall return a non-negative integer, namely a shared memory identifier;
  93. otherwise, it shall return \-1 and set
  94. .IR errno
  95. to indicate the error.
  96. .SH ERRORS
  97. The
  98. \fIshmget\fR()
  99. function shall fail if:
  100. .TP
  101. .BR EACCES
  102. A shared memory identifier exists for
  103. .IR key
  104. but operation permission as specified by the low-order nine bits of
  105. .IR shmflg
  106. would not be granted; see
  107. .IR "Section 2.7" ", " "XSI Interprocess Communication".
  108. .TP
  109. .BR EEXIST
  110. A shared memory identifier exists for the argument
  111. .IR key
  112. but (\fIshmflg\fR &IPC_CREAT) &&(\fIshmflg\fR &IPC_EXCL) is non-zero.
  113. .TP
  114. .BR EINVAL
  115. A shared memory segment is to be created and the value of size is
  116. less than the system-imposed minimum or greater than the
  117. system-imposed maximum.
  118. .TP
  119. .BR EINVAL
  120. No shared memory segment is to be created and a shared memory
  121. segment exists for
  122. .IR key
  123. but the size of the segment associated with it is less than
  124. .IR size .
  125. .TP
  126. .BR ENOENT
  127. A shared memory identifier does not exist for the argument
  128. .IR key
  129. and (\fIshmflg\fP &IPC_CREAT) is 0.
  130. .TP
  131. .BR ENOMEM
  132. A shared memory identifier and associated shared memory segment are to
  133. be created, but the amount of available physical memory is not
  134. sufficient to fill the request.
  135. .TP
  136. .BR ENOSPC
  137. A shared memory identifier is to be created, but the system-imposed
  138. limit on the maximum number of allowed shared memory identifiers
  139. system-wide would be exceeded.
  140. .LP
  141. .IR "The following sections are informative."
  142. .SH EXAMPLES
  143. None.
  144. .SH "APPLICATION USAGE"
  145. The POSIX Realtime Extension defines alternative interfaces for interprocess
  146. communication. Application developers who need to use IPC should
  147. design their applications so that modules using the IPC routines
  148. described in
  149. .IR "Section 2.7" ", " "XSI Interprocess Communication"
  150. can be easily modified to use the alternative interfaces.
  151. .SH RATIONALE
  152. None.
  153. .SH "FUTURE DIRECTIONS"
  154. None.
  155. .SH "SEE ALSO"
  156. .IR "Section 2.7" ", " "XSI Interprocess Communication",
  157. .IR "Section 2.8" ", " "Realtime",
  158. .IR "\fIftok\fR\^(\|)",
  159. .IR "\fIshmat\fR\^(\|)",
  160. .IR "\fIshmctl\fR\^(\|)",
  161. .IR "\fIshmdt\fR\^(\|)",
  162. .IR "\fIshm_open\fR\^(\|)",
  163. .IR "\fIshm_unlink\fR\^(\|)"
  164. .P
  165. The Base Definitions volume of POSIX.1\(hy2017,
  166. .IR "Section 3.346" ", " "Shared Memory Object",
  167. .IR "\fB<sys_shm.h>\fP"
  168. .\"
  169. .SH COPYRIGHT
  170. Portions of this text are reprinted and reproduced in electronic form
  171. from IEEE Std 1003.1-2017, Standard for Information Technology
  172. -- Portable Operating System Interface (POSIX), The Open Group Base
  173. Specifications Issue 7, 2018 Edition,
  174. Copyright (C) 2018 by the Institute of
  175. Electrical and Electronics Engineers, Inc and The Open Group.
  176. In the event of any discrepancy between this version and the original IEEE and
  177. The Open Group Standard, the original IEEE and The Open Group Standard
  178. is the referee document. The original Standard can be obtained online at
  179. http://www.opengroup.org/unix/online.html .
  180. .PP
  181. Any typographical or formatting errors that appear
  182. in this page are most likely
  183. to have been introduced during the conversion of the source files to
  184. man page format. To report such errors, see
  185. https://www.kernel.org/doc/man-pages/reporting_bugs.html .