This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 5.002_01: lib/File/Basename.pm
[perl5.git] / eg / shmkill
CommitLineData
378cc40b
LW
1#!/usr/bin/perl
2
79072805 3# $RCSfile: shmkill,v $$Revision: 4.1 $$Date: 92/08/07 17:20:45 $
378cc40b
LW
4
5# A script to call from crontab periodically when people are leaving shared
6# memory sitting around unattached.
7
a687059c 8open(ipcs,'ipcs -m -o|') || die "Can't run ipcs: $!";
378cc40b
LW
9
10while (<ipcs>) {
11 $tmp = index($_,'NATTCH');
12 $pos = $tmp if $tmp >= 0;
13 if (/^m/) {
14 ($m,$id,$key,$mode,$owner,$group,$attach) = split;
15 if ($attach != substr($_,$pos,6)) {
a687059c 16 die "Different ipcs format--can't parse!\n";
378cc40b
LW
17 }
18 if ($attach == 0) {
19 push(@goners,'-m',$id);
20 }
21 }
22}
23
24exec 'ipcrm', @goners if $#goners >= 0;