shmdt()--Detach Shared Memory Segment from Calling Process


  Syntax
 #include <sys/shm.h>

 int shmdt(const void *shmaddr);  

  Service Program Name: QP0ZUSHR

  Default Public Authority: *USE

  Threadsafe: Yes

The shmdt() function detaches the shared memory segment specified by shmaddr from the calling job. The shmaddr is the value returned by the shmat() function.

The system maintains status information about a shared memory segment which can be retrieved with the shmctl() function. When a shared memory segment is successfully detached, the system sets the members of the shmid_ds structure as follows:


Parameters

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

Authorities

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 shared memory segment has been 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 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, use the shmctl() function with the cmd parameter set to IPC_RMID.

Related Information


Example

For an example of using this function, see Example: Using semaphore set and shared memory functions.



API introduced: V3R6

[ Back to top | UNIX-Type APIs | APIs by category ]