3 .\" Copyright (c) 1999-2002 Apple Computer, Inc. All rights reserved.
5 .\" @APPLE_LICENSE_HEADER_START@
7 .\" The contents of this file constitute Original Code as defined in and
8 .\" are subject to the Apple Public Source License Version 1.1 (the
9 .\" "License"). You may not use this file except in compliance with the
10 .\" License. Please obtain a copy of the License at
11 .\" http://www.apple.com/publicsource and read it before using this file.
13 .\" This Original Code and all software distributed under the License are
14 .\" distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 .\" EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 .\" INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 .\" FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
18 .\" License for the specific language governing rights and limitations
19 .\" under the License.
21 .\" @APPLE_LICENSE_HEADER_END@
28 .Nd open a shared memory object
30 .Fd #include <sys/mman.h>
31 .Fd #include <fcntl.h>
34 .Fa "const char *name"
39 The parameter "mode_t mode" is optional.
41 The shared memory object referenced by
43 is opened for reading and/or writing as specified by the argument
45 and the file descriptor returned to the calling process.
46 The returned file descriptor will be the lowest non-open file
47 descriptor for the calling process, and is not shared with any
48 other processes, as it is a new file descriptor. The new file
49 descriptor will have the
55 with the same string value for
57 will return a file descriptor referring to the same shared memory
58 object, provided that the object has not been unlinked by a call to
62 argument may indicate the file is to be
63 created if it does not exist (by specifying the
65 flag), in which case the file is created with mode
69 and modified by the process' umask value (see
78 .Bd -literal -offset indent -compact
79 O_RDONLY open for reading only
80 O_RDWR open for reading and writing
81 O_CREAT create object if it does not exist
82 O_EXCL error if create and object exists
83 O_TRUNC truncate size to 0
95 file exists, the file is truncated to zero length.
103 returns an error. This may be used to
104 implement a simple exclusive access locking mechanism.
108 returns a non-negative integer, termed a file descriptor.
109 It returns -1 and sets
112 The file pointer used to mark the current position within the
113 memory object is set to the beginning of the object.
115 When a new shared memory object is created it is given the
116 owner and group corresponding to the effective user and
117 group of the calling process. There is no visible entry in the
118 file system for the created object in this implementation.
120 When a shared memory object is created, it persists until it
121 it unlinked and all other references are gone. Objects do
122 not persist across a system reboot.
124 The system imposes a limit on the number of file descriptors
125 open simultaneously by one process.
127 returns the current system limit.
129 The named object is opened unless:
132 The required permissions (for reading and/or writing)
133 are denied for the given flags.
136 is specified, the object does not exist, and permission to
137 create the object is denied.
142 were specified and the object exists.
146 operation was interrupted by a signal.
150 operation is not supported.
152 The process has already reached its limit for open file descriptors.
153 .It Bq Er ENAMETOOLONG
155 exceeded the name size limit.
158 characters (defined in
159 .In sys/posix_shm.h ) ,
160 but this may change in the future.
162 The system file table is full.
165 is not set and the named object does not exist.
168 is specified, the file does not exist, and there is insufficient
169 space available to create the object.
174 .Xr getdtablesize 2 ,
180 is specified in the POSIX Realtime Extension (1003.1b-1993/1003.1i-1995).