*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->FreeBSD man pages -> shm_open (3)              
Title
Content
Arch
Section
 

SHM_OPEN(3)

Contents


NAME    [Toc]    [Back]

     shm_open -- open or create a shared memory object shm_unlink -- remove a
     shared memory object

LIBRARY    [Toc]    [Back]

     Standard C Library (libc, -lc)

SYNOPSIS    [Toc]    [Back]

     #include <sys/types.h>
     #include <sys/mman.h>

     int
     shm_open(const char *path, int flags, mode_t mode);

     int
     shm_unlink(const char *path);

DESCRIPTION    [Toc]    [Back]

     The shm_open() function opens (or optionally creates) a POSIX shared memory
 object named path.  The shm_unlink() function removes a shared memory
     object named path.

     In the FreeBSD implementation, POSIX shared memory objects are implemented
 as ordinary files.	The shm_open() and shm_unlink() act as wrappers
 around the open(2) and unlink(2) routines, and path, flags, and mode
     arguments are as specified for those functions.  The flags argument is
     checked to ensure that the access mode specified is not O_WRONLY (which
     is not defined for shared memory objects).

     In addition, the FreeBSD implementation causes mmap() of a descriptor
     returned by shm_open() to behave as if the MAP_NOSYNC flag had been specified
 to mmap(2).	(It does so by setting a special file flag using
     fcntl(2).)

     The shm_unlink() function makes no effort to ensure that path refers to a
     shared memory object.

COMPATIBILITY    [Toc]    [Back]

     The path argument does not necessarily represent a pathname (although it
     does in this and most other implementations).  Two processes opening the
     same path are guaranteed to access the same shared memory object if and
     only if path begins with a slash (`/') character.

     Only the O_RDONLY, O_RDWR, O_CREAT, O_EXCL, and O_TRUNC flags may be used
     in portable programs.

     The result of using open(2), read(2), or write(2) on a shared memory
     object, or on the descriptor returned by shm_open(), is undefined.  It is
     also undefined whether the shared memory object itself, or its contents,
     persist across reboots.

RETURN VALUES    [Toc]    [Back]

     If successful, shm_open() returns a non-negative integer; shm_unlink()
     returns zero.  Both functions return -1 on failure, and set errno to
     indicate the error.

ERRORS    [Toc]    [Back]

     The shm_open() and shm_unlink() functions can fail with any error defined
     for open() and unlink(), respectively.  In addition, the following errors
     are defined for shm_open():

     [EINVAL]		The object named by path is not a shared memory object
			(i.e., it is not a regular file).

     [EINVAL]		The flags argument to shm_open() specifies an access
			mode of O_WRONLY.

SEE ALSO    [Toc]    [Back]

      
      
     mmap(2), munmap(2), open(2), unlink(2)

STANDARDS    [Toc]    [Back]

     The shm_open() and shm_unlink() functions are believed to conform to IEEE
     Std 1003.1b-1993 (``POSIX.1'').

HISTORY    [Toc]    [Back]

     The shm_open() and shm_unlink() functions first appeared in FreeBSD 4.3.

AUTHORS    [Toc]    [Back]

     Garrett A. Wollman <wollman@FreeBSD.org> (C library support and this manual
 page)

     Matthew Dillon <dillon@FreeBSD.org> (MAP_NOSYNC)


FreeBSD 5.2.1			March 24, 2000			 FreeBSD 5.2.1
[ Back ]
 Similar pages
Name OS Title
shm_open HP-UX create/open a shared memory object
shm_unlink FreeBSD remove a shared memory object
shm_open Tru64 Opens a shared memory object, creating the object if necessary (P1003.1b)
shm_unlink IRIX deletes a shared memory object
shm_unlink HP-UX unlink a shared memory object
shm_open IRIX establishes a connection between a shared memory object and a file descriptor
shm_unlink Tru64 Removes a shared memory object created by a call to the shm_open function (P1003.1b)
dlopen IRIX open a shared object
sgidladd IRIX open a shared object and add its variables to the name space.
sgidlopen_version IRIX open a shared object with the specified interface version.
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service