diff options
Diffstat (limited to 'eg/shmkill')
-rw-r--r-- | eg/shmkill | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/eg/shmkill b/eg/shmkill new file mode 100644 index 0000000000..ba288d8e0d --- /dev/null +++ b/eg/shmkill @@ -0,0 +1,24 @@ +#!/usr/bin/perl + +# $Header: shmkill,v 2.0 88/06/05 00:16:59 root Exp $ + +# A script to call from crontab periodically when people are leaving shared +# memory sitting around unattached. + +open(ipcs,'ipcs -m -o|') || die "Can't run ipcs"; + +while (<ipcs>) { + $tmp = index($_,'NATTCH'); + $pos = $tmp if $tmp >= 0; + if (/^m/) { + ($m,$id,$key,$mode,$owner,$group,$attach) = split; + if ($attach != substr($_,$pos,6)) { + die "Different ipcs format--can't parse!"; + } + if ($attach == 0) { + push(@goners,'-m',$id); + } + } +} + +exec 'ipcrm', @goners if $#goners >= 0; |