| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 3: Basic Library Functions Oracle Solaris 11 Information Library |
enable_extended_FILE_stdio(3C)
posix_spawnattr_getschedparam(3C)
posix_spawnattr_getschedpolicy(3C)
posix_spawnattr_getsigdefault(3C)
posix_spawnattr_getsigignore_np(3C)
posix_spawnattr_getsigmask(3C)
posix_spawnattr_setschedparam(3C)
posix_spawnattr_setschedpolicy(3C)
posix_spawnattr_setsigdefault(3C)
posix_spawnattr_setsigignore_np(3C)
posix_spawnattr_setsigmask(3C)
posix_spawn_file_actions_addclose(3C)
posix_spawn_file_actions_addclosefrom_np(3C)
posix_spawn_file_actions_adddup2(3C)
posix_spawn_file_actions_addopen(3C)
posix_spawn_file_actions_destroy(3C)
posix_spawn_file_actions_init(3C)
pthread_attr_getdetachstate(3C)
pthread_attr_getinheritsched(3C)
pthread_attr_getschedparam(3C)
pthread_attr_getschedpolicy(3C)
pthread_attr_setdetachstate(3C)
pthread_attr_setinheritsched(3C)
pthread_attr_setschedparam(3C)
pthread_attr_setschedpolicy(3C)
pthread_barrierattr_destroy(3C)
pthread_barrierattr_getpshared(3C)
pthread_barrierattr_setpshared(3C)
pthread_condattr_getpshared(3C)
pthread_condattr_setpshared(3C)
pthread_cond_reltimedwait_np(3C)
pthread_key_create_once_np(3C)
pthread_mutexattr_getprioceiling(3C)
pthread_mutexattr_getprotocol(3C)
pthread_mutexattr_getpshared(3C)
pthread_mutexattr_getrobust(3C)
pthread_mutexattr_setprioceiling(3C)
pthread_mutexattr_setprotocol(3C)
pthread_mutexattr_setpshared(3C)
pthread_mutexattr_setrobust(3C)
pthread_mutex_getprioceiling(3C)
pthread_mutex_reltimedlock_np(3C)
pthread_mutex_setprioceiling(3C)
pthread_rwlockattr_destroy(3C)
pthread_rwlockattr_getpshared(3C)
pthread_rwlockattr_setpshared(3C)
pthread_rwlock_reltimedrdlock_np(3C)
pthread_rwlock_reltimedwrlock_np(3C)
pthread_rwlock_timedrdlock(3C)
pthread_rwlock_timedwrlock(3C)
rctlblk_get_enforced_value(3C)
- receive a message from a message queue
#include <mqueue.h>ssize_tmq_receive(mqd_tmqdes,char *msg_ptr,size_tmsg_len,unsigned *msg_prio);
#include <mqueue.h>#include <time.h>ssize_tmq_timedreceive(mqd_tmqdes,char *restrictmsg_ptr,size_tmsg_len,unsigned *restrictmsg_prio,const struct timespec *restrictabs_timeout);
ssize_tmq_reltimedreceive_np(mqd_tmqdes,char *restrictmsg_ptr,size_tmsg_len,unsigned *restrictmsg_prio,const struct timespec *restrictrel_timeout);
Themq_receive() function receives the oldest of the highest priority message(s) fromthe message queue specified bymqdes. If the size of the bufferin bytes, specified bymsg_len, is less than themq_msgsize member of themessage queue, the function fails and returns an error. Otherwise, the selectedmessage is removed from the queue and copied to the buffer pointedto bymsg_ptr.
If the value ofmsg_len is greater than {SSIZE_MAX}, the result isimplementation-defined.
Ifmsg_prio is notNULL, the priority of the selected message isstored in the location referenced bymsg_prio.
If the specified message queue is empty andO_NONBLOCK is notset in the message queue description associated withmqdes, (seemq_open(3C) andmq_setattr(3C)),mq_receive() blocks, waiting until a message is enqueued on the messagequeue, or untilmq_receive() is interrupted by a signal. If more thanone process (or thread) is waiting to receive a message when amessage arrives at an empty queue, then the process of highest prioritythat has been waiting the longest is selected to receive the message.If the specified message queue is empty andO_NONBLOCK is set inthe message queue description associated withmqdes, no message is removed fromthe queue, andmq_receive() returns an error.
Themq_timedreceive() function receives the oldest of the highest priority messages fromthe message queue specified bymqdes as described for themq_receive() function.However, ifO_NONBLOCK was not specified when the message queue was opened withthemq_open(3C) function, and no message exists on the queue to satisfythe receive, the wait for such a message is terminated when the specifiedtimeout expires. IfO_NONBLOCK is set, this function is equivalent tomq_receive().
Themq_reltimedreceive_np() function is identical to themq_timedreceive() function, except that thetimeout is specified as a relative time interval.
Formq_timedreceive(), the timeout expires when the absolute time specified byabs_timeoutpasses, as measured by theCLOCK_REALTIME clock (that is, when the valueof that clock equals or exceedsabs_timeout), or if the absolute time specifiedbyabs_timeout has already been passed at the time of the call.
Formq_reltimedreceive_np(), the timeout expires when the time interval specified byrel_timeoutpasses, as measured by theCLOCK_REALTIME clock, or if the time intervalspecified byrel_timeout is negative at the time of the call.
The resolution of the timeout is the resolution of theCLOCK_REALTIME clock.Thetimespec argument is defined in the <time.h> header.
Under no circumstance does the operation fail with a timeout if amessage can be removed from the message queue immediately. The validity ofthe timeout parameter need not be checked if a message can beremoved from the message queue immediately.
Upon successful completion,mq_receive(),mq_timedreceive(), andmq_reltimedreceive_np() return the length of theselected message in bytes and the message is removed from the queue.Otherwise, no message is removed from the queue, the functions return a valueof-1, and setserrno to indicate the error condition.
Themq_receive(),mq_timedreceive(), andmq_reltimedreceive_np() functions will fail if:
O_NONBLOCK was set in the message description associated withmqdes, and the specified message queue is empty.
Themqdes argument is not a valid message queue descriptor open for reading.
The function was interrupted by a signal.
The process or thread would have blocked, and the timeout parameter specified a nanoseconds field value less than zero or greater than or equal to 1,000 million.
The specified message buffer size,msg_len, is less than the message size member of the message queue.
TheO_NONBLOCK flag was not set when the message queue was opened, but no message arrived on the queue before the specified timeout expired.
Themq_receive(),mq_timedreceive(), andmq_reltimedreceive_np() functions may fail if:
A data corruption problem with the message has been detected.
Seeattributes(5) for descriptions of the following attributes:
|
Formq_receive() andmq_timedreceive(). seestandards(5).
mqueue.h(3HEAD),mq_open(3C),mq_send(3C),mq_setattr(3C),attributes(5),standards(5)
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |