|
|||||||
|
|
MSGOPSection: Linux Programmer's Manual (2)Updated: 2002-06-01 Index Return to Main Contents NAMEmsgop - message operationsSYNOPSIS#include <sys/types.h> int msgsnd(int msqid, struct msgbuf *msgp, size_t msgsz, int msgflg); ssize_t msgrcv(int msqid, struct msgbuf *msgp, size_t msgsz, long msgtyp, int msgflg); DESCRIPTIONTo send or receive a message, the calling process allocates a structure of the following general form:
struct msgbuf {
The The calling process must have write permission to send and read permission to receive a message on the queue. The msgsnd system call appends a copy of the message pointed to by msgp to the message queue whose identifier is specified by msqid. If sufficient space is available on the queue, msgsnd succeeds immediately. (The queue capacity is defined by the msg_bytes field in the associated data structure for the message queue. During queue creation this field is initialised to MSGMNB bytes, but this limit can be modified using msgctl.) If insufficient space is available on the queue, then the default behaviour of msgsnd is to block until space becomes available. If IPC_NOWAIT is asserted in msgflg then the call instead fails with the error EAGAIN. A blocked msgsnd call may also fail if the queue is removed (in which case the system call fails with errno set to EIDRM), or a signal is caught (in which case the system call fails with errno set to EINTR). (msgsnd and msgrcv are never automatically restarted after being interrupted by a signal handler, regardless of the setting of the SA_RESTART flag when establishing a signal handler.) Upon successful completion the message queue data structure is updated as follows:
The system call msgrcv reads a message from the message queue specified by msqid into the msgbuf pointed to by the msgp argument, removing the read message from the queue. The argument msgsz specifies the maximum size in bytes for the member mtext of the structure pointed to by the msgp argument. If the message text has length greater than msgsz, then if the msgflg argument asserts MSG_NOERROR, the message text will be truncated (and the truncated part will be lost), otherwise the message isn't removed from the queue and the system call fails returning with errno set to E2BIG. The argument msgtyp specifies the type of message requested as follows:
The msgflg argument asserts none, one or more (or-ing them) of the following flags:
If no message of the requested type is available and IPC_NOWAIT isn't asserted in msgflg, the calling process is blocked until one of the following conditions occurs:
Upon successful completion the message queue data structure is updated as follows:
RETURN VALUEOn a failure both functions return -1 with errno indicating the error, otherwise msgsnd returns 0 and msgrvc returns the number of bytes actually copied into the mtext array.ERRORSWhen msgsnd fails, at return errno will be set to one among the following values:
When msgrcv fails, at return errno will be set to one among the following values:
NOTESThe followings are system limits affecting a msgsnd system call:
The implementation has no intrinsic limits for the system wide maximum number of message headers (MSGTQL) and for the system wide maximum size in bytes of the message pool (MSGPOOL). CONFORMING TOSVr4, SVID.NOTEThe pointer argument is declared as struct msgbuf * with libc4, libc5, glibc 2.0, glibc 2.1. It is declared as void * (const void * for msgsnd()) with glibc 2.2, following the SUSv2.SEE ALSOipc(5), msgctl(2), msgget(2), msgrcv(2), msgsnd(2)
Index | ||||||
|
|
|
Home :: Copyright :: Privacy :: Credits :: Get a free Linuxinfor Email Account Document on this page is part of "Linuxinfor Man Pages in HTML Format: man2". See Index Page for more info about Authorship and Copyright. 1999-2008 Linuxinfor.com. No rights reserved. |