Removal of all the message queues in system
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Removal of all the message queues in system




Pages (2): [1] 2 »   Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Removal of all the message queues in system  
Ash


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-18-04 03:42 PM

Is it possible to write a C program that could remove ALL the message
queues in the system?





[ Post a follow-up to this message ]



    Re: Removal of all the message queues in system  
Michael Kerrisk


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-19-04 07:34 AM

On 17 Apr 2004 02:09:58 -0700, amujoo@yahoo.com (Ash) wrote:

>Is it possible to write a C program that could remove ALL the message
>queues in the system?

Yes.  There are non-portable implementation specific methods (what
implementation are you using), or alternatively you can parse the
output of ipcs(1).

Cheers,

Michael





[ Post a follow-up to this message ]



    Re: Removal of all the message queues in system  
Ash


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-20-04 07:36 PM

can you please give me a piece of C code to perform removal of all
message queues. i am not able to think of anything. i dont think
parsing ipcs output is a good idea.

Michael Kerrisk <michael.kerrisk.at.gmx.net@nospam.com> wrote in message news:<3lr680tpk2c50
ba50sai2jllf3ocu8k2l9@4ax.com>...
> On 17 Apr 2004 02:09:58 -0700, amujoo@yahoo.com (Ash) wrote:
> 
>
> Yes.  There are non-portable implementation specific methods (what
> implementation are you using), or alternatively you can parse the
> output of ipcs(1).
>
> Cheers,
>
> Michael





[ Post a follow-up to this message ]



    Re: Removal of all the message queues in system  
Dragan Cvetkovic


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-20-04 07:36 PM

amujoo@yahoo.com (Ash) writes:

> Michael Kerrisk <michael.kerrisk.at.gmx.net@nospam.com> wrote in message n
ews:<3lr680tpk2c50ba50sai2jllf3ocu8k2l9@4ax.com>... 
[vbcol=seagreen]
> can you please give me a piece of C code to perform removal of all
> message queues. i am not able to think of anything. i dont think
> parsing ipcs output is a good idea.
>

Well, it depends on the OS. On Solaris for example you can use msgids(2) to
get the list of message queue identifiers and then use msgctl(2) to remove
them one by one.

HTH, Dragan


--
Dragan Cvetkovic,

To be or not to be is true. G. Boole      No it isn't.  L. E. J. Brouwer

!!! Sender/From address is bogus. Use reply-to one !!!





[ Post a follow-up to this message ]



    Re: Removal of all the message queues in system  
Michael Kerrisk


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-21-04 07:34 AM

On 20 Apr 2004 10:50:32 -0700, amujoo@yahoo.com (Ash) wrote:

>can you please give me a piece of C code to perform removal of all
>message queues. i am not able to think of anything. i dont think
>parsing ipcs output is a good idea.

Ahh, no I can't -- first of all because you didn't answer the
question: what implementation are you using?

Cheers,

Michael[vbcol=seagreen]
>
>Michael Kerrisk <michael.kerrisk.at.gmx.net@nospam.com> wrote in message ne
ws:<3lr680tpk2c50ba50sai2jllf3ocu8k2l9@4ax.com>... 






[ Post a follow-up to this message ]



    Re: Removal of all the message queues in system  
Ash


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-21-04 07:34 AM

Dragan Cvetkovic <me@privacy.net> wrote in message news:<lm4qrejyqz.fsf@privacy.net>...[vbco
l=seagreen]
> amujoo@yahoo.com (Ash) writes:
> 
> 
>
> Well, it depends on the OS. On Solaris for example you can use msgids(2) t
o
> get the list of message queue identifiers and then use msgctl(2) to remove
> them one by one.
>
> HTH, Dragan[/vbcol]


But even msgids is not present in Sol 8. On Red Hat linux there isnt
any such syscall. So how would it be possible on linux? Any clues?





[ Post a follow-up to this message ]



    Re: Removal of all the message queues in system  
Dragan Cvetkovic


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-21-04 12:35 PM

amujoo@yahoo.com (Ash) writes:

> Dragan Cvetkovic <me@privacy.net> wrote in message news:<lm4qrejyqz.fsf@pr
ivacy.net>... 
[vbcol=seagreen]
>
> But even msgids is not present in Sol 8. On Red Hat linux there isnt
> any such syscall. So how would it be possible on linux? Any clues?

Strange. msgids(2) is available on Solaris 8 systems I have access to. What
revision of it you have? I have no ideas about Linux though.

Bye, Dragan

--
Dragan Cvetkovic,

To be or not to be is true. G. Boole      No it isn't.  L. E. J. Brouwer

!!! Sender/From address is bogus. Use reply-to one !!!





[ Post a follow-up to this message ]



    Re: Removal of all the message queues in system  
Michael Kerrisk


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-22-04 08:36 AM

On Wed, 21 Apr 2004 07:30:57 -0400, Dragan Cvetkovic <me@privacy.net>
wrote:

>amujoo@yahoo.com (Ash) writes:
> 
> 
>
>Strange. msgids(2) is available on Solaris 8 systems I have access to. What
>revision of it you have? I have no ideas about Linux though.

(It's also available on the Solaris 8 systems that I can access.)

The OP seems intent on not listening to advice or answering
questions ;-)  : parsing the output of ipcs is *the* most portable way
of solving this problem.

It appears from the above post that the OP is interested primarily in
Solaris and Linux.  Dragan has posted the Solaris-specific alternative
to parsing ipcs output.

On Linux, there are two different ways of solving this problem:

-- read the contents of /proc/sysvipc/msg (Linux 2.4 and later)

-- make use of the IPC_INFO and MSG_STAT msgctl() operations

Both of the above methods are *not* portable.  The second of these
techniques is shown below.

Cheers,

Michael



/* List all System V message queues */

#define _GNU_SOURCE
#include <sys/ipc.h>
#include <sys/msg.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>

#define errMsg(msg) 	{ perror(msg); }

#define errExit(msg) 	{ perror(msg); exit(EXIT_FAILURE); }

int
main(int argc, char *argv[])
{
int maxind, ind, msqid;
struct msqid_ds ds;
struct msginfo msginfo;

/* Obtain size of kernel 'entries' array */

maxind = msgctl(0, IPC_INFO, (struct msqid_ds *) &msginfo);
if (maxind == -1) errExit("msgctl");

printf("maxind: %d\n\n", maxind);
printf("index     id       key      messages\n");

for (ind = 0; ind <= maxind; ind++) {
msqid = msgctl(ind, MSG_STAT, &ds);
if (msqid == -1) {
if (errno != EINVAL && errno != EACCES)
errMsg("msgctl-MSG_STAT");      /* Unexpected error */
continue;                           /* Ignore this item */
}

printf("%4d %8d  0x%08x %7ld\n", ind, msqid,
ds.msg_perm.__key, (long) ds.msg_qnum);
}

exit(EXIT_SUCCESS);
} /* main */





[ Post a follow-up to this message ]



    Re: Removal of all the message queues in system  
Ash


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-22-04 09:34 AM

Michael Kerrisk <michael.kerrisk.at.gmx.net@nospam.com> wrote in message news:<gn2c80tl32hju
qap6gmantj5uv1m9btd38@4ax.com>...[vbcol=seagreen]
> On 20 Apr 2004 10:50:32 -0700, amujoo@yahoo.com (Ash) wrote:
> 
>
> Ahh, no I can't -- first of all because you didn't answer the
> question: what implementation are you using?
>
> Cheers,
>
> Michael 

I have access to Sol 8 machine, in which I tried man msgids. and it
says man page not found. Then I want to get this thing done on Linux
where no such thing could found. I would need a C code.

Thanks
ash





[ Post a follow-up to this message ]



    Re: Removal of all the message queues in system  
Casper H.S. Dik


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-22-04 10:34 AM

amujoo@yahoo.com (Ash) writes:

>I have access to Sol 8 machine, in which I tried man msgids. and it
>says man page not found. Then I want to get this thing done on Linux
>where no such thing could found. I would need a C code.

The Solaris 8 system I tried it on does have the msgids/shmids/semids
manual pages.  You can also check docs.sun.com for the specific manual
pages.

Older releases did go throught the trouble of reading /dev/kmem.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 04:47 AM.      Post New Thread    Post A Reply      
Pages (2): [1] 2 »   Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register