[OpenBSD]

Manual Page Search Parameters

SHM_OPEN(3) Library Functions Manual SHM_OPEN(3)

NAME

shm_open, shm_unlink, shm_mkstempcreate and destroy shared memory objects

SYNOPSIS

#include <sys/mman.h>
int
shm_open(const char *path, int flags, mode_t mode);
int
shm_unlink(const char *path);
int
shm_mkstemp(char *template);

DESCRIPTION

The shm_open() function opens a shared memory object and returns a file descriptor suitable for use with mmap(2). The flags argument has the same meaning as provided to open(2) and must include at least O_RDONLY or O_RDWR and may also include a combination of O_CREAT, O_EXCL, O_CLOEXEC, O_NOFOLLOW, or O_TRUNC. This implementation forces the mode to be 0600 or 0400, and prohibits sharing between different UIDs.
shm_unlink() is used to remove a shared memory object. The object is not freed until all references to it have been released via close(2).
If a temporary shared memory object is desired, the shm_mkstemp() function should be preferred as it avoids several possible security holes that tend to appear in programs trying to create their own unique temporary names. The template argument is a string with at least six trailing Xs as described in mkstemp(3).

RETURN VALUES

shm_open() and shm_mkstemp() return a file descriptor on successful completion. They may fail for any of the reasons listed in open(2).

SEE ALSO

mmap(2)

STANDARDS

shm_open() and shm_unlink() appear in IEEE Std 1003.1-2001 (“POSIX.1”). Using O_CLOEXEC or O_NOFOLLOW with shm_open() is an extension to that standard. This implementation deviates from the standard by permitting less sharing.
shm_mkstemp() is an extension.

HISTORY

The shm_open(), shm_unlink(), and shm_mkstemp() functions have been available since OpenBSD 5.4.

AUTHORS

Ted Unangst <tedu@openbsd.org>.
May 5, 2015 OpenBSD-current