Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
614 B

  1. #!/usr/bin/perl
  2. # $RCSfile: shmkill,v $$Revision: 4.1 $$Date: 92/08/07 17:20:45 $
  3. # A script to call from crontab periodically when people are leaving shared
  4. # memory sitting around unattached.
  5. open(ipcs,'ipcs -m -o|') || die "Can't run ipcs: $!";
  6. while (<ipcs>) {
  7. $tmp = index($_,'NATTCH');
  8. $pos = $tmp if $tmp >= 0;
  9. if (/^m/) {
  10. ($m,$id,$key,$mode,$owner,$group,$attach) = split;
  11. if ($attach != substr($_,$pos,6)) {
  12. die "Different ipcs format--can't parse!\n";
  13. }
  14. if ($attach == 0) {
  15. push(@goners,'-m',$id);
  16. }
  17. }
  18. }
  19. exec 'ipcrm', @goners if $#goners >= 0;