PSTAT Interfaces
15
This call returns information describing System V message queues. Each structure
returned describes one message queue identifier on the system. For each instance data up to a
maximum of elemsize bytes are returned in the structs pst_msginfo pointed to by buf. The
elemcount parameter specifies the number of structs pst_msginfo that are available at buf. The
index parameter specifies the starting index within the context of System V message queues. As
a shortcut, information for a single message queue may be obtained by setting elemcount to zero
and setting index to the msqid of that message queue.
Return Value:
This call returns –1 on failure or number of instances copied to buf on success.
Errors:
• EINVAL is set if the user's size declaration isn't valid.
• EINVAL is set if the initial selection, index, isn't valid.
• ESRCH is set if the specific-msqid shortcut is used and there is no message queue with that ID
• EACCES is set if the specific-msqid shortcut is used and the caller does not have read
permission to the message queue.
• EFAULT is set if buf points to invalid address.
Example:
#include <sys/pstat.h>
#include <stdlib.h>
#include <errno.h>
void main(void)
{
struct pst_ipcinfo psi;
struct pst_msginfo *psmp;
long msgmni;
int qs_inuse;
/* Get total message Qs */
if ((pstat_getipc(&psi, sizeof(psi), 1, 0) == -1) &&
(errno != EOVERFLOW)) {
printf("\nCould not get ipc info");
exit(1);
}
msgmni = psi.psi_msgmni;
psmp = (struct pst_msginfo *)
malloc(msgmni * sizeof(struct pst_msginfo));
/* Get Qs in use */
qs_inuse = pstat_getmsg(psmp, sizeof(struct pst_msginfo), msgmni, 0);
if (qs_inuse == -1) {
printf("\n Could not get msg info");
exit(1);
}
free(psmp);
printf("\n Total Qs = %d", msgmni);
printf("\n Qs in use = %d", qs_inuse);
printf("\nQs not in use = %d\n", msgmni - qs_inuse);
}
4.13 pstat_getnode()
Synopsis: