Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

flushing shm keys

by vijesh (Novice)
on Jun 07, 2013 at 05:36 UTC ( #1037581=perlquestion: print w/replies, xml ) Need Help??
vijesh has asked for the wisdom of the Perl Monks concerning the following question:

Hello Experts, Appreciate your help here. what is the command to flush shmget-key? At times, I see that when I use same used key, it is still pointing to old value. How do I flush it/reinitialize to null value. Thanks, Vijesh

my $key=int(rand(900))+5; my $size = 100; $id = shmget($key, $size, &IPC_CREAT | 0777 );

Replies are listed 'Best First'.
Re: flushing shm keys
by Khen1950fx (Canon) on Jun 07, 2013 at 07:08 UTC
    To flush the key:
    #!/usr/bin/perl -l use strict; use warnings; use IPC::SysV qw(IPC_CREAT IPC_RMID); $| = 1; my $key = int( rand(900) ) + 5; my $size = 100; my $id = shmget( $key, $size, &IPC_CREAT | 0777 ); print "creating shm key $id"; print "flushing shm key $id"; shmctl( $id, IPC_RMID, 1 );
    You can reset to 0 by putting $id = 0; at the EOF.

      Thanks you very much.. this works. Vijesh

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1037581]
Approved by davido
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (11)
As of 2018-07-20 10:47 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (428 votes). Check out past polls.