Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ msgsnd(3) — AIX PS/2 1.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

msgctl

msgget

msgrcv

msgxrcv

sigaction, sigvec, signal



MSGSND(3,L)                 AIX Technical Reference                 MSGSND(3,L)



-------------------------------------------------------------------------------
msgsnd



PURPOSE

Sends a message.

LIBRARY

Standard C Library (libc.a)

SYNTAX

#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>

int msgsnd (msqid, msgp, msgsz, msgflg)
int msqid;
struct msgbuf *msgp;
int msgsz, msgflg;

DESCRIPTION

The msgsnd system call sends a message to the queue specified by the msqid
parameter.  The current process must have write permission in order to perform
this operation.  The msgp parameter points to a msgbuf structure containing the
message.  The msgbuf structure is defined in the sys/msg.h header file, and it
contains the following members:

      long  mtype;     /* Message type */
      char  mtext[1];  /* Beginning of message text */

The mtype parameter is a positive integer that is used by the receiving process
for message selection.  The mtext parameter is any text of the length in bytes
specified by the msgsz parameter.  The msgsz parameter can range from 0 to a
system-imposed maximum.

The msgflg parameter specifies the action to be taken if the message cannot be
sent for one of the following reasons:

  o The number of bytes already on the queue is equal to msg_qbytes.

  o The total number of messages on all queues system-wide is equal to a
    system-imposed limit.

These actions are as follows:

  o If msgflg is set to IPC_NOWAIT, then the message is not sent, and msgsnd
    returns a value of -1 and sets errno to EAGAIN.



Processed November 7, 1990        MSGSND(3,L)                                 1





MSGSND(3,L)                 AIX Technical Reference                 MSGSND(3,L)




  o If msgflg is 0, then the calling process suspends execution until one of
    the following occurs:

      - The condition responsible for the suspension no longer exists, in which
        case the message is sent.

      - msqid is removed from the system.  (For information on how to remove
        msqid, see "msgctl.") When this occurs, errno is set equal to EIDRM,
        and a value of -1 is returned.

      - The calling process receives a signal that is to be caught.  In this
        case the message is not sent and the calling process resumes execution
        in the manner prescribed in "sigaction, sigvec, signal."

Warning:  If the Transparent Computing Facility is installed, a message queue
exists only on the cluster site on which the queue was created.  There is no
provision for accessing a message queue on a remote cluster site.
Consequently, processes that use message queues cannot be migrated to other
sites.

RETURN VALUE

Upon successful completion, a value of 0 is returned and the following actions
are taken with respect to the data structure associated with the msqid
parameter:

  o msg_qnum is incremented by 1.
  o msg_lspid is set equal to the process ID of the calling process.
  o msg_stime is set equal to the current time.

If the msgsnd system call fails, a value of -1 is returned and errno is set to
indicate the error.

ERROR CONDITIONS

The msgsnd system call fails and no message is sent if one or more of the
following are true:

EINVAL  The msqid parameter is not a valid message queue identifier.

EACCES  Operation permission is denied to the calling process.

EINVAL  mtype is less than 1.

EAGAIN  The message cannot be sent for one of the reasons stated previously,
        and msgflg is set to IPC_NOWAIT.

EINVAL  The msgsz parameter is less than 0 or greater than the system-imposed
        limit.





Processed November 7, 1990        MSGSND(3,L)                                 2





MSGSND(3,L)                 AIX Technical Reference                 MSGSND(3,L)



EFAULT  The msgp parameter points to a location outside of the process's
        allocated address space.

EINTR   msgsnd received a signal.

EIDRM   The message queue identifier specified by msqid has been removed from
        the system.

RELATED INFORMATION

In this book:  "msgctl,"  "msgget,"  "msgrcv," "msgxrcv," and  "sigaction,
sigvec, signal."











































Processed November 7, 1990        MSGSND(3,L)                                 3



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026