The shmdt() function detaches the shared memory segment located at the address specified by shmaddr from the address space of the calling process. The to-be-detached segment must be currently attached with shmaddr equal to the value returned by the attaching shmat() function. On a successful shmdt() function the system updates the members of the shmid_ds structure associated with the shared memory segment as follows: o shm_dtime is set to the current time. o shm_lpid is set to the process-ID of the calling process. o shm_nattch is decremented by one. If it becomes zero and the segment is marked for deletion, the segment is deleted. For more information see the shmctl function. Upon exit, all the attached shared memory segments are detached from the process.