Penguin
Annotated edit history of msgop(2) version 3, including all changes. View license author blame.
Rev Author # Line
1 perry 1 !!NAME
2 PerryLorier 2 msgop - message operations
1 perry 3
4 !!SYNOPSIS
2 PerryLorier 5 __#include <sys/types.h>__
6 __#include <sys/ipc.h>__
7 __#include <sys/msg.h>__
8 __int msgsnd ( int__ ''msqid''__, struct msgbuf *__''msgp''__, size_t__ ''msgsz''__, int__ ''msgflg'' __)__
1 perry 9
2 PerryLorier 10 __ssize_t msgrcv ( int__ ''msqid''__, struct msgbuf *__''msgp''__, size_t__ ''msgsz''__, long__ ''msgtyp''__, int__ ''msgflg'' __)__
1 perry 11
12 !!DESCRIPTION
2 PerryLorier 13 To send or receive a message, the calling process allocates a structure that looks like the following
1 perry 14
3 PerryLorier 15 __struct msgbuf {__
2 PerryLorier 16 __long mtype;__ /* message type, must be __
17 __char mtext[[1];__ /* message data */__
18 __};__
1 perry 19
2 PerryLorier 20 but with an array __mtext__ of size ''msgsz'', a non-negative integer value. The structure member __mtype__ must have a strictly positive integer value
21 that can be used by the receiving process for message selection (see the section about __msgrcv__).
1 perry 22
2 PerryLorier 23 The calling process must have write access permissions to send and read access permissions to receive a message on the queue.
1 perry 24
2 PerryLorier 25 The __msgsnd__ system call enqueues a copy of the message pointed to by the ''msgp'' argument on the message queue whose identifier is specified by the value of the ''msqid'' argument.
1 perry 26
2 PerryLorier 27 The argument ''msgflg'' specifies the system call behaviour if enqueuing the new message will require more than __msg_qbytes__ in the queue. Asserting __IPC_NOWAIT__ the message will not be sent and the system call fails returning with __errno__ set to [EAGAIN]. Otherwise the process is suspended until the condition for the suspension no longer exists (in which case the message is sent and the system call succeeds), or the queue is removed (in which case the system call fails with __errno__ set to [EIDRM]), or the process receives a signal that has to be caught (in which case the system call fails with __errno__ set to [EINTR]).
1 perry 28
29
2 PerryLorier 30 Upon successful completion the message queue data structure is updated as follows:
1 perry 31
2 PerryLorier 32 __msg_lspid__ is set to the process-ID of the calling process.
1 perry 33
34 __msg_qnum__ is incremented by 1.
35
36 __msg_stime__ is set to the current time.
37
2 PerryLorier 38 The system call __msgrcv__ reads a message from the message queue specified by ''msqid'' into the __msgbuf__ pointed to by the ''msgp'' argument removing from the queue, on success, the read message.
1 perry 39
2 PerryLorier 40 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),
41 otherwise the message isn't removed from the queue and the system call fails returning with __errno__ set to [E2BIG].
1 perry 42
43
2 PerryLorier 44 The argument ''msgtyp'' specifies the type of message requested as follows:
1 perry 45
2 PerryLorier 46 If ''msgtyp'' is __0__, then the message on the queue's front is read.
1 perry 47
2 PerryLorier 48 If ''msgtyp'' is greater than __0__, then the first message on the queue of type ''msgtyp'' is read if __MSG_EXCEPT__ isn't asserted by the ''msgflg''
49 argument, otherwise the first message on the queue of type not equal to ''msgtyp'' will be read.
1 perry 50
2 PerryLorier 51 If ''msgtyp'' is less than __0__, then the first message on the queue with the lowest type less than or equal to the absolute value of ''msgtyp'' will be
1 perry 52 read.
53
2 PerryLorier 54 The ''msgflg'' argument asserts none, one or more (or-ing them) among the following flags:
1 perry 55
2 PerryLorier 56 __IPC_NOWAIT__ For immediate return if no message of the requested type is on the queue. The system call fails with errno set to __ENOMSG__.
1 perry 57
2 PerryLorier 58 __MSG_EXCEPT__ Used with ''msgtyp'' greater than __0__ to read the first message on the queue with message type that differs from ''msgtyp''.
1 perry 59
2 PerryLorier 60 __MSG_NOERROR__ To truncate the message text if longer than ''msgsz'' bytes.
1 perry 61
2 PerryLorier 62 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:
1 perry 63
2 PerryLorier 64 A message of the desired type is placed on the queue.
1 perry 65
2 PerryLorier 66 The message queue is removed from the system. In such a case the system call fails with __errno__ set to [EIDRM].
1 perry 67
2 PerryLorier 68 The calling process receives a signal that has to be caught. In such a case the system call fails with __errno__ set to [EINTR].
1 perry 69
2 PerryLorier 70 Upon successful completion the message queue data structure is updated as follows:
1 perry 71
2 PerryLorier 72 __msg_lrpid__ is set to the process-ID of the calling process.
1 perry 73
74 __msg_qnum__ is decremented by 1.
75
2 PerryLorier 76 __msg_rtime__ is set to the current time.
1 perry 77
78 !!RETURN VALUE
2 PerryLorier 79 On 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.
1 perry 80
81 !!ERRORS
2 PerryLorier 82 When __msgsnd__ fails, at return __errno__ will be set to one among the following values:
1 perry 83
2 PerryLorier 84 ;[EAGAIN]: The message can't be sent due to the __msg_qbytes__ limit for the queue and __IPC_NOWAIT__ was asserted in ''mgsflg''.
85 ;[EACCES]: The calling process has no write access permissions on the message queue.
86 ;[EFAULT]: The address pointed to by ''msgp'' isn't accessible.
87 ;[EIDRM]: The message queue was removed.
88 ;[EINTR]: Sleeping on a full message queue condition, the process received a signal that had to be caught.
89 ;[EINVAL]: Invalid ''msqid'' value, or nonpositive ''mtype'' value, or invalid ''msgsz'' value (less than 0 or greater than the system value __MSGMAX__).
90 ;[ENOMEM]: The system has not enough memory to make a copy of the supplied __msgbuf__.
1 perry 91
2 PerryLorier 92 When __msgrcv__ fails, at return __errno__ will be set to one among the following values:
1 perry 93
2 PerryLorier 94 ;[E2BIG]: The message text length is greater than ''msgsz'' and __MSG_NOERROR__ isn't asserted in ''msgflg''.
95 ;[EACCES]: The calling process has no read access permissions on the message queue.
96 ;[EFAULT]: The address pointed to by ''msgp'' isn't accessible.
97 ;[EIDRM]: While the process was sleeping to receive a message, the message queue was removed.
98 ;[EINTR]: While the process was sleeping to receive a message, the process received a signal that had to be caught.
99 ;[EINVAL]: Illegal ''msgqid'' value, or ''msgsz'' less than __0__.
100 ;[ENOMSG]: __IPC_NOWAIT__ was asserted in ''msgflg'' and no message of the requested type existed on the message queue.
1 perry 101
102 !!NOTES
2 PerryLorier 103 The followings are system limits affecting a __msgsnd__ system call:
104 ;__MSGMAX__: Maximum size for a message text: the implementation set this value to 4080 bytes.
105 ;__MSGMNB__: Default maximum size in bytes of a message queue: policy dependent. The super-user can increase the size of a message queue beyond __MSGMNB__ by a __msgctl__ system call.
1 perry 106
2 PerryLorier 107 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
108 pool (__MSGPOOL__).
1 perry 109
110 !!CONFORMING TO
2 PerryLorier 111 SVr4, SVID.
1 perry 112
113 !!NOTE
2 PerryLorier 114 The 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
115 glibc 2.2, following the SUSv2.
1 perry 116
117 !!SEE ALSO
2 PerryLorier 118 ipc(5), msgctl(2), msgget(2), msgrcv(2), msgsnd(2)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.

PHP Warning

lib/blame.php:177: Warning: Invalid argument supplied for foreach() (...repeated 11 times)