File: ipcl

package info (click to toggle)
wine 0.0.20000109-3
  • links: PTS
  • area: main
  • in suites: potato
  • size: 22,652 kB
  • ctags: 59,973
  • sloc: ansic: 342,054; perl: 3,697; yacc: 3,059; tcl: 2,647; makefile: 2,466; lex: 1,494; sh: 394
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);
}