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

msgctl

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

Provides message control operations.

Syntax

G613



   #include <sys/types.h>

   #include <sys/ipc.h>

   #include <sys/msg.h>



   int msgctl (int msqid, int cmd,

   struct msqid_ds *buffer);

Parameters

msqid

Passes a message queue identifier returned by a call to msgget().

cmd

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

buffer

Passes a pointer to a buffer of type struct msqid_ds (defined in the <sys/msg.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 msgctl() function provides message control operations on the message queue and data structure associated with msqid. Control operations are defined by the cmd parameter. Following are valid commands to be passed in cmd:

IPC_RMID

Deallocate the message queue identifier specified by msqid and purge the message queue and data structure associated with it. The calling process must have either MPE/iX SM capability, or be the owner or creator of msqid (have an effective user ID equal to the value of either the msg_perm.uid (owner) or msg_perm.cuid (creator) fields in the data structure associated with msqid).

IPC_SET

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

  • msg_perm.uid (owner user ID)

  • msg_perm.gid (owner group ID)

  • Low order 9 bits of msg_perm.mode

  • msg_qbytes

The calling process must have either MPE/iX SM capability or an effective user ID equal to the value of either the msg_perm.uid or msg_perm.cuid fields in the data structure associated with msqid. The caller must have MPE/iX SM capability to increase the value of the msg_qbytes field of the data structure associated with msqid.

IPC_STAT

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

Implementation Considerations

None.

Errors

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

EACCESCAUSE cmd specifies IPC_STAT and the calling process does not have read permission.
 ACTION Ensure that the calling process has read permission for the msqid.
EFAULTCAUSE The system detected a NULL or bad address in attempting to use the buffer argument.
 ACTION Check to see if the pointer is correctly initialized.
EINVALCAUSE msqid is not a valid message queue identifier, or cmd is not a valid command.
 ACTION Check that the msqid parameter is valid and the associated message queue has not been removed, or that cmd is valid.
EPERMCAUSE

One of the following:

  • cmd 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 msg_perm.uid or msg_perm.cuid fields in the data structure associated with msqid.

  • cmd specifies IPC_SET and the calling process tried to increase the value of msg_qbytes without having MPE/iX SM capability.

 ACTION Ensure that the calling process has the appropriate effective user ID or capability required to perform the requested command.
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

msgget(), msgrcv(), msgsnd(), SVID2 (Section 12)

Feedback to webmaster