SYNOPSIS
#include <sys/mman.h>
int shm_open(const char *name, int oflag, mode_t mode);
DESCRIPTION
The
When successful,
The file status flags and file access modes of the open file description are set according to the value of oflag. The oflag argument is the bitwise-inclusive OR of the following flags defined in the <fcntl.h> header. Applications specify exactly one of the first two values (access modes) below in the value of oflag:
Any combination of the remaining flags may be specified in the value of oflag:
- O_CREAT
-
When the shared memory object exists, this flag has no effect, except as noted under O_EXCL below. Otherwise, the shared memory object is created; the user ID of the shared memory object is set to the effective user ID of the process; the group ID of the shared memory object is set to a system default group ID or to the effective group ID of the process. The permission bits of the shared memory object are set to the value of the mode argument except those set in the file mode creation mask of the process. The mode argument does not affect whether the shared memory object is opened for reading, for writing, or for both. The shared memory object has a size of zero.
- O_EXCL
-
When O_EXCL and O_CREAT are set,
shm_open() fails if the shared memory object exists. The check for the existence of the shared memory object and the creation of the object if it does not exist is atomic with respect to other processes executingshm_open() naming the same shared memory object with O_EXCL and O_CREAT set. - O_TRUNC
-
When the shared memory object exists, and it is successfully opened O_RDWR, the object is truncated to zero length and the mode and owner is unchanged by this function call.
When a shared memory object is created, the state of the shared memory object, including all data associated with the shared memory object, persists until the shared memory object is unlinked and all other references are gone.
PARAMETERS
- mode
-
Specifies the values to be set for the permission bits of the created shared memory object.
- name
-
Points to the name to be assigned to the created shared memory object.
- oflag
-
Specifies the file status flags and file access modes to be used with the open file description .
RETURN VALUES
On success, the
- EACCES
-
The shared memory object exists and the permissions specified by oflag are denied, or the shared memory object does not exist and permission to create the shared memory object is denied, or O_TRUNC is specified and write permission is denied.
- EEXIST
-
O_CREAT and O_EXCL are set and the named shared memory object already exists.
- EINTR
-
The
shm_open() operation was interrupted by a signal. - EINVAL
-
The
shm_open() operation is not supported for the given name. - EMFILE
-
Too many file descriptors are currently in use by this process.
- ENAMETOOLONG
-
The name argument is too long.
- ENFILE
-
Too many shared memory objects are currently open in the system.
- ENOENT
-
O_CREAT is not set and the named shared memory object does not exist.
- ENOSPC
-
There is insufficient space for the creation of the new shared memory object.
CONFORMANCE
UNIX 03.
MULTITHREAD SAFETY LEVEL
MT-Safe.
PORTING ISSUES
When compiling programs that use this function, you must specify
the
AVAILABILITY
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
SEE ALSO
- Functions:
close() ,dup() ,exec() ,fcntl() ,mmap() ,shm_unlink() ,shmat() ,shmctl() ,shmdt() ,umask()
PTC MKS Toolkit 10.5 Documentation Build 40.