Run like this: perl clearshm.pl jryan. That will remove all shared memory segments and sephamore arrays created the user jryan. Quite handy for when Shared Memory created by IPC::Shareable goes outta control, as well as other uses. Special thanks to fokat for clueing me in on the commands needed to do this :)
#!/usr/bin/perl -w use strict; my @input =`ipcs`; @input = grep (/$ARGV[0]/, @input); foreach my $line (@input) { my @entry = split (/\s+/, $line); my $test = `ipcrm sem $entry[1]` if (scalar(@entry) == 5); $test = `ipcrm shm $entry[1]` if (scalar(@entry) == 6); print "Result for id $entry[1]: $test" if $test; }