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

  man pages->NetBSD man pages -> shmget (2)              
Title
Content
Arch
Section
 

SHMGET(2)

Contents


NAME    [Toc]    [Back]

     shmget - get shared memory segment

LIBRARY    [Toc]    [Back]

     Standard C Library (libc, -lc)

SYNOPSIS    [Toc]    [Back]

     #include <sys/shm.h>

     int
     shmget(key_t key, size_t size, int shmflg);

DESCRIPTION    [Toc]    [Back]

     shmget() returns the shared memory identifier associated with the key
     key.  The shmflg should be a combination of the following flags:

           IPC_CREAT   create if segment does not exist

           IPC_EXCL    fail if segment already exists

           IPC_NOWAIT  return error instead of waiting

     and nine bits of access bits, based on:

           IPC_R  read permission

           IPC_W  write permission

           IPC_M  changing control info permission

     A shared memory segment is created if either key is equal to IPC_PRIVATE,
     or key does not have a shared memory segment identifier associated with
     it, and the IPC_CREAT bit is set in shmflg.

     If a new shared memory segment is created, the data structure associated
     with it (the shmid_ds structure, see shmctl(2)) is initialized as follows:


     +o   shm_perm.cuid and shm_perm.uid are set to the effective uid of the
         calling process.

     +o   shm_perm.gid and shm_perm.cgid are set to the effective gid of the
         calling process.

     +o   shm_perm.mode is set to the lower 9 bits of shmflg.

     +o   shm_lpid, shm_nattch, shm_atime, and shm_dtime are set to 0.

     +o   shm_ctime is set to the current time.

     +o   shm_segsz is set to the value of size.

RETURN VALUES    [Toc]    [Back]

     Upon successful completion a positive shared memory segment identifier is
     returned.  Otherwise, -1 is returned and the global variable errno is set
     to indicate the error.

ERRORS    [Toc]    [Back]

     [EACCES]           A shared memory segment is already associated with key
                        and the caller has no permission to access it.

     [EEXIST]           Both IPC_CREAT and IPC_EXCL are set in shmflg, and a
                        shared memory segment is already associated with key.

     [ENOSPC]           A new shared memory identifier could not be created
                        because the system limit for the number of shared memory
 identifiers has been reached.

     [ENOENT]           IPC_CREAT is not set in shmflg and no shared memory
                        segment associated with key was found.

     [ENOMEM]           There is not enough memory left to create a shared
                        memory segment of the requested size.

SEE ALSO    [Toc]    [Back]

      
      
     mmap(2), shmat(2), shmctl(2), ftok(3)

STANDARDS    [Toc]    [Back]

     The shmget system call conforms to X/Open System Interfaces and Headers
     Issue 5 (``XSH5'').

HISTORY    [Toc]    [Back]

     Shared memory segments appeared in the first release of AT&T System V
     UNIX.

BSD                             August 25, 1999                            BSD
[ Back ]
 Similar pages
Name OS Title
shmget Linux allocates a shared memory segment
shmget IRIX get shared memory segment identifier
shmmax HP-UX maximum size (in bytes) for a System V shared memory segment
shmmni HP-UX number of System V shared memory segment identifiers in the system
shm_open FreeBSD open or create a shared memory object shm_unlink -- remove a shared memory object
mlock HP-UX lock a segment of the process virtual address space in memory
XmStringInitContext Tru64 A compound string function that allows applications to read out the content segment by segment
XmStringInitContext IRIX A compound string function that allows applications to read out the content segment by segment
shmat HP-UX shared memory operations
shmdt NetBSD map/unmap shared memory
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service