File: ipcl

package info (click to toggle)
wine 0.0.980315-1
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 10,136 kB
  • ctags: 26,112
  • sloc: ansic: 156,310; makefile: 1,160; yacc: 807; perl: 655; lex: 555; sh: 304
file content (62 lines) | stat: -rwxr-xr-x 1,222 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/perl

#
# Copyright 1995. Michael Veksler.
#

$IPC_RMID=0;
$USER=$ENV{USER};

open(IPCS,"ipcs|");

#
# The following part is OS dependant, it works under linux only.
# To make it work under other OS 
# You should fill in @shm, @sem, @msq lists, with the relevent IPC
# keys.

#
# This code was written to be as much as possible generic, but...
# It works for Linux and ALPHA. I had no BSD machine to test it.
# (As I remember, AIX will work also).

while(<IPCS>) {
    split;

    # try to find out the IPC-ID, assume it is the first number.
    foreach (@_) {
	$_ ne int($_) && next;	# not a decimal number
	$num=$_;
	last;
    }
    if (/mem/i .. /^\s*$/ ) {
	index($_,$USER)>=0 || next;
	push(@shm,$num);
    }
    if (/sem/i .. /^\s*$/ ) {
	index($_,$USER)>=0 || next;
	push(@sem,$num);
    }
    if (/mes/i .. /^\s*$/ ) {
	index($_,$USER)>=0 || next;
	push(@msq,$num);
    }
}


#
# This is the end of OS dependant code.
#

@shm && print "shmid ", join(":",@shm),"\n";
@sem && print "semid ", join(":",@sem),"\n";
@msq && print "msqid ", join(":",@msq),"\n";
foreach (@shm) {
    shmctl($_, $IPC_RMID,0);
}
foreach (@sem) {
    semctl($_, 0, $IPC_RMID,0);
}
foreach (@msq) {
    msgctl($_, $IPC_RMID,0);
}