[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 2

shmdt Subroutine

Purpose

Detaches a shared memory segment.

Library

Standard C Library (libc.a)

Syntax

#include <sys/shm.h>


int shmdt (SharedMemoryAddress)
const void * SharedMemoryAddress;

Description

The shmdt subroutine detaches from the data segment of the calling process the shared memory segment located at the address specified by the SharedMemoryAddress parameter.

Mapped file segments are automatically detached when the mapped file is closed. However, you can use the shmdt subroutine to explicitly release the segment register used to map a file. Shared memory segments must be explicitly detached with the shmdt subroutine.

If the file was mapped for writing, the shmdt subroutine updates the mtime and ctime time stamps.

The following limits apply to shared memory:

Parameters

SharedMemoryAddress Specifies the data segment start address of a shared memory segment.

Return Values

When successful, the shmdt subroutine returns a value of 0. Otherwise, the shared memory segment at the address specified by the SharedMemoryAddress parameter is not detached, a value of 1 is returned, and the errno global variable is set to indicate the error.

Error Codes

The shmdt subroutine is unsuccessful if the following condition is true:

EINVAL The value of the SharedMemoryAddress parameter is not the data-segment start address of a shared memory segment.

Related Information

The exec subroutine, exit subroutine, fork subroutine, fsync subroutine, mmap subroutine, munmap subroutine, shmat subroutine, shmctl subroutine, shmget subroutine.

The ipcs command and ipcrm command.

List of Memory Manipulation Services, Subroutines Overview, Understanding Memory Mapping in AIX 5L Version 5.2 General Programming Concepts: Writing and Debugging Programs.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]