shmdt()-Detach Shared Memory Segment from Calling Process



Syntax

#include <sys/shm.h>

int shmdt(const void *shmaddr);


Threadsafe: Yes

The shmdt() function detaches the shared memory segment specified by shmaddr from the calling process.

Parameters

shmaddr
(Input) Address of the shared memory segment to be detached.

Authorities

Figure 1-16. Authorization Required for shmdt()
Object Referred to Authority Required errno
Shared memory segment to be detached None None

Return Value

0
shmdt() was successful.
-1
shmdt() was not successful. The errno variable is set to indicate the error.

Error Conditions

If shmdt() is not successful, errno usually indicates one of the following errors. Under some conditions, errno could indicate an error other than those listed here.

[EDAMAGE]
A damaged object was encountered.

The value of shmid corresponds to a shared memory ID that has been marked as damaged by a previous shared memory operation.

[EFAULT]
The address used for an argument is not correct.

In attempting to use an argument in a call, the system detected an address that is not valid.

While attempting to access a parameter passed to this function, the system detected an address that is not valid.

[EINVAL]
The value specified for the argument is not correct.

A function was passed incorrect argument values, or an operation was attempted on an object and the operation specified is not supported for that type of object.

An argument value is not valid, out of range, or NULL.

The value of shmaddr is not the data segment start address of a shared memory segment.

[ENOSYS]
Function not implemented.

An attempt was made to use a function that is not available in this implementation for any object or any arguments.

The function is not implemented.

[EUNKNOWN]
Unknown system state.

The operation failed because of an unknown system state. See any messages in the job log and correct any errors that are indicated, then retry the operation.

Error Messages

None.

Usage Notes

  1. This function does not delete the shared memory segment. To delete a shared memory segment, a shmctl() call specifying a cmd parameter of IPC_RMID must be used.

Related Information

Example

For an example of using this function, see Using Semaphores and Shared Memory in Appendix A, Examples.


Top | Interprocess Communication APIs | APIs by category


[Information Center Home Page | Feedback ] [Legal | AS/400 Glossary]