Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 46. System V Message Queues > Displaying All Message Queues on the Syst...

46.6. Displaying All Message Queues on the System

In Section 45.7, we looked at one way to obtain a list of all of the IPC objects on the system: via a set of files in the /proc file system. We now look at a second method of obtaining the same information: via a set of Linux-specific IPC ctl (msgctl(), semctl(), and shmctl()) operations. (The ipcs program employs these operations.) These operations are as follows:

  • MSG_INFO, SEM_INFO, and SHM_INFO: The MSG_INFO operation serves two purposes. First, it returns a structure detailing resources consumed by all message queues on the system. Second, as the function result of the ctl call, it returns the index of the maximum item in the entries array pointing to data structures for the message queue objects (see Figure 45-1, in Section 45.5). The SEM_INFO and SHM_INFO operations perform an analogous task for semaphore sets and shared memory segments, respectively. We must define the _GNU_SOURCE feature test macro to obtain the definitions of these three constants from the corresponding System V IPC header files.


    Note:

    An example showing the use of MSG_INFO to retrieve a msginfo structure containing information about resources used by all message queue objects is provided in the file svmsg/svmsg_info.c in the source code distribution for this book.


  • MSG_STAT, SEM_STAT, and SHM_STAT: Like the IPC_STAT operation, these operations retrieve the associated data structure for an IPC object. However, they differ in two respects. First, instead of expecting an IPC identifier as the first argument of the ctl call, these operations expect an index into the entries array. Second, if the operation is successful, then, as its function result, the ctl call returns the identifier of the IPC object corresponding to that index. We must define the _GNU_SOURCE feature test macro to obtain the definitions of these three constants from the corresponding System V IPC header files.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial