Can a msg queue be 'peeked' rather than 'read' ?

Can a msg queue be 'peeked' rather than 'read' ?

Post by Kevin Grindle » Fri, 27 Nov 1998 04:00:00



Hi,
    I would like to look at the contents of a message queue without
removing the message  from the queue. This would seem to rule out the
use of msgrcv() out as far as I can tell. So, I tried to read the
contents of a test queue I created via the msqid_ds and msg structures
defined (on my system) in <sys.msg.h> . However this failed with a
segmentation error when I tried to access the message type of the first
message on the queue. Using a debug utility I tried to dump the contents
of core at the message type location but this produceced no output at
all.

    This sounds like I have corrupted memory myself or that I am not
allowed to read that part of memory - unless the process is owned by
root perhaps (??) I guess this could be an OS-specific issue but there
is no group dedicated to the system on which I develop (SVR4 Dynix/ptx)
so I apologise.

    Can anyone confirm that the areas of  memory reserved for these
kernel-maintianed structures are generally unreadable by non-root owned
processes ? Or (even better !) can anyone suggest a technique for
'peeking' rather than 'reading/removing' a message on a message queue  ?

    Thanks,
    Kev.

 
 
 

1. Can a msg queue be 'peeked' rather than read ?

Hi,
    I would like to look at the contents of a message queue without
removing the message  from the queue. This would seem to rule out the
use of msgrcv() out as far as I can tell. So, I tried to read the
contents of a test queue I created via the msqid_ds and msg structures
defined (on my system) in <sys.msg.h> . However this failed with a
segmentation error when I tried to access the message type of the first
message on the queue. Using a debug utility I tried to dump the contents

of core at the message type location but this produceced no output at
all.

    This sounds like I have corrupted memory myself or that I am not
allowed to read that part of memory - unless the process is owned by
root perhaps (??) I guess this could be an OS-specific issue but there
is no group dedicated to the system on which I develop (SVR4 Dynix/ptx)
so I apologise.

    Can anyone confirm that the areas of  memory reserved for these
kernel-maintianed structures are generally unreadable by non-root owned
processes ? Or (even better !) can anyone suggest a technique for
'peeking' rather than 'reading/removing' a message on a message queue  ?

    Thanks,
    Kev.

2. Alpha/Beta testers wanted for X11 tracker

3. I've read/am reading the faq's - but what is a Segmentation fault?

4. IP masq and MS Exchange

5. My 'made-by-printtool' lp queue doesn't queue.

6. too many files in one directory

7. patchadd/checkinstall failure ('nobody' /does/ have read permission on '.' and parents)

8. AIX - Deleted /var - help!

9. different behaviour of 'while read' and 'for' loops in bash

10. 'make' fails, and I don't understand the error msg

11. Perl5.001 error msg: can't find library 'libdb.so.1'

12. Question on 'tar' error msg's

13. xinit : can't load library 'libXt.so.6' error msg.