Home Man
Today's Posts

Linux & Unix Commands - Search Man Pages
Man Page or Keyword Search:
Select Section of Man Page:
Select Man Page Repository:

NetBSD 6.1.5 - man page for shmget (netbsd section 2)

SHMGET(2)			     BSD System Calls Manual				SHMGET(2)

     shmget -- get shared memory segment

     Standard C Library (libc, -lc)

     #include <sys/shm.h>

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

     shmget() returns the shared memory identifier associated with the key key.

     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 both the IPC_CREAT bit and the IPC_EXCL bit are set in shmflg, and key has a
     shared memory segment identifier associated with it already, the operation will fail.

     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.

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

     [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 seg-
			ment is already associated with key.

     [EINVAL]		No shared memory segment is to be created, and a shared memory segment
			exists for key, but the size of the segment associated with it is less
			than size, which is non-zero.

			A shared memory segment is to be created, and size is less than the sys-
			tem imposed minimum, or greater than the system imposed maximum (refer to
			the kern.ipc values in sysctl(7)).

     [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.

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

     ipcrm(1), ipcs(1), mmap(2), shmat(2), shmctl(2), ftok(3), sysctl(7)

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

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

BSD					 October 27, 2008				      BSD

All times are GMT -4. The time now is 06:18 PM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
Show Password

Not a Forum Member?
Forgot Password?