http://www.perlmonks.org?node_id=929034

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

i need to cretae a message queue for interprocess communication. i ma able to generate key as shown below $msgkey = IPC::SysV::ftok("$APPSYS/runner/.runnerrc$NODE", 1); variables are specific o my system. but when i am trying to generate queue identifier like $msgID = msgget($msgkey, IPC_CREAT | S_IRWXU); its failing ..i am not getting any value for $msgID.it throws Illegal seek error . Can nayone pls propose a solution Thank you

Replies are listed 'Best First'.
Re: interprocess communication ($!)
by tye (Sage) on Oct 02, 2011 at 01:15 UTC
    it throws Illegal seek error.

    I doubt that. Perl's msgget() never 'throws', it just returns undef to indication failure. If you are printing an error message that include $! that then say "Illegal seek", that likely has little to do with your call to msgget(). The underlying system's msgget(2) doesn't appear to be able to fail for that reason.

    Most likely, you are reporting $! even though msgget() didn't actually fail or you are doing too much before $! is output such that the value of $! gets overwritten.

    - tye        

Re: interprocess communication
by Khen1950fx (Canon) on Oct 02, 2011 at 04:42 UTC
    I think that you're seeing a warning, not an error. Try it without the warnings pragma.
    #!/usr/bin/perl -l use strict; use IPC::SysV qw(ftok IPC_CREAT S_IRWXU); my $key = ftok("/tmp/sometest.pl", 'A'); print my $id = msgget($key, IPC_CREAT | S_IRWXU );
Re: interprocess communication
by Marshall (Canon) on Oct 01, 2011 at 15:03 UTC
    No. No thank you. Your post shows a lot of disrespect for the forum.

    Update: It was wrong for me to have said that - too aggressive. I will say that the best way to generate lots of helpful suggestions here is to be polite.

    Being polite means among other things, just taking the time to correct and use the spell checker suggestions before your post si sic("is") finalized.

      Well, more to the point, it at-least does not give anyone enough specific detail to act upon. Short code-snippets (or longer ones prepared as per "Markup in the Monastery") are needed. And of course it's often the case that while you are preparing those snippets, you spot the bug... "duh, never mind."