shm_unlink()

Remove a shared memory object

Synopsis:

#include <sys/mman.h>

int shm_unlink( const char * name );

Arguments:

name
The name of the shared memory object that you want to remove.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The shm_unlink() function removes the name of the shared memory object specified by name. After removing the name, you can't use shm_open() to access the object.

This function doesn't affect any references to the shared memory object (i.e. file descriptors or memory mappings). If more than one reference to the shared memory object exists, then the link count is decremented, but the shared memory segment isn't actually removed until you remove all open and map references to it.

Returns:

0
Success.
-1
An error occurred (errno is set).

Errors:

EACCES
Permission to unlink the shared memory object is denied.
ELOOP
Too many levels of symbolic links or prefixes.
ENAMETOOLONG
The length of the name argument exceeds NAME_MAX.
ENOENT
The named shared memory object doesn't exist, or the name argument points to an empty string.
ENOSYS
The shm_unlink() function isn't supported by this implementation.

Examples:

See shm_open().

Classification:

POSIX 1003.1 SHM

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

mmap(), munmap(), mprotect(), shm_ctl(), shm_ctl_special(), shm_open()