[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Base Operating System and Extensions Technical Reference, 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.

Implementation Specifics

This subroutine is part of Base Operating System (BOS) Runtime.

Related Information

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

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


[ Previous | Next | Contents | Glossary | Home | Search ]