summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/perl/eg/shmkill
blob: e8d1b11b3630a955d386f6cf660fd9404de8b243 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/perl

# $Header: /home/cvs/386BSD/ports/lang/perl/eg/shmkill,v 1.1.1.1 1993/08/23 21:29:43 nate 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!\n";
	}
	if ($attach == 0) {
	    push(@goners,'-m',$id);
	}
    }
}

exec 'ipcrm', @goners if $#goners >= 0;
OpenPOWER on IntegriCloud