home *** CD-ROM | disk | FTP | other *** search
/ ftp.muug.mb.ca / 2014.06.ftp.muug.mb.ca.tar / ftp.muug.mb.ca / pub / src / perl / eg / shmkill < prev    next >
Text File  |  1992-04-11  |  582b  |  25 lines

  1. #!/usr/bin/perl
  2.  
  3. # $Header: shmkill,v 4.0 91/03/20 01:14:20 lwall Locked $
  4.  
  5. # A script to call from crontab periodically when people are leaving shared
  6. # memory sitting around unattached.
  7.  
  8. open(ipcs,'ipcs -m -o|') || die "Can't run ipcs: $!";
  9.  
  10. while (<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)) {
  16.         die "Different ipcs format--can't parse!\n";
  17.     }
  18.     if ($attach == 0) {
  19.         push(@goners,'-m',$id);
  20.     }
  21.     }
  22. }
  23.  
  24. exec 'ipcrm', @goners if $#goners >= 0;
  25.