HPlogo MPE/iX Developer's Kit Reference Manual Volume 2: HP 3000 MPE/iX Computer Systems > Chapter 2 SVID IPC Library Function Descriptions

shmctl

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

Performs control operations on a shared memory area.

Syntax

   #include <sys/types.h>

   #include <sys/ipc.h>

   #include <sys/shm.h>



   int shmctl (int shmid, int cmd, struct shmid_ds *buffer);

Parameters

shmid

Passes a shared memory identifier returned by a call to shmget().

cmd

Passes a command defining the control operation to perform. Valid control codes are defined in the "Description" section below.

buffer

Passes a pointer to a buffer of type struct shmid_ds (defined in the <sys/shm.h> header). Operations on the buffer are defined by cmd. Refer to the "Description" section below.

Return Values

0

Success.

-1

An error occurred, and errno is set to indicate the error condition.

Description

The shmctl() function performs control operations on shmid and its associated shared memory area and data structure. Control operations are defined by the cmd parameter. Following are valid commands to be passed in cmd:

IPC_RMID

Deallocate the shared memory identifier specified by shmid and purge the shared memory area and data structure associated with it. If the shared memory area is attached to one or more processes the shared memory area key is changed to IPC_PRIVATE and the area is marked removed. The area is purged only when the last attached process detaches from it.

The calling process must have either MPE/iX SM capability or be the owner or creator of the shared memory area (have an effective user ID equal to the value of either the shm_perm.uid (owner) or shm_perm.cuid (creator) fields in the data structure associated with shmid).

IPC_SET

Copy data from the following fields of the shmid_ds structure pointed to by buffer to the corresponding fields in the data structure associated with shmid:

  • shm_perm.uid (owner user ID)

  • shm_perm.gid (owner group ID)

  • Low order 9 bits of shm_perm.mode

The calling process must have either MPE/iX SM capability or an effective user ID equal to the value of either the shm_perm.uid or shm_perm.cuid fields in data structure associated with shmid.

IPC_STAT

Copy all data from the structure associated with shmid to the data structure pointed to by buffer.

Implementation Considerations

The SHM_LOCK and SHM_UNLOCK options of cmd are not implemented. A call to shmctl() with cmd set to either SHM_LOCK or SHM_UNLOCK results in an error.

Errors

If an error occurs, errno is set to one of the following values.

EACCESCAUSE cmd is set to IPC_STAT and the calling process does not have read permission.
 ACTION Ensure that the calling process has read permission to the shared memory area.
EFAULTCAUSE The system detected a NULL or bad address in attempting to use the buffer argument.
 ACTION Check to see if the pointer is properly initialized.
EINVALCAUSE shmid is not a valid shared memory identifier, or cmd is not a valid command, or cmd specifies SHM_UNLOCK or SHM_LOCK.
 ACTION Check that shmid is valid and that the identifier has not been removed from the system, and check that cmd specifies a valid, supported command.
ENOMEMCAUSE cmd specifies SHM_LOCK or the available data space is not large enough to accommodate the shared memory area.
 ACTION None.
EPERMCAUSEcmd specifies IPC_RMID or IPC_SET and the calling process does not have either MPE/iX SM capability or an effective user ID equal to the value of either the shm_perm.uid (owner) or shm_perm.cuid (creator) fields in the data structure associated with shmid.
 ACTION Ensure that the calling process has the appropriate effective user ID or the appropriate capabilities to perform the specified cmd.
ESYSERRCAUSE An operating system error occurred that does not map directly to any of the above errors.
 ACTION Examine the MPE/iX process error stack for the type of system error.

See Also

shmat(), shmdt(), shmget(), SVID2 (Section 12)

Feedback to webmaster