blob: 53710a629ecf41636ec695aca224f488d004b66c (
plain) (
blame)
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
|
#!@PERL@
#
# $Id$
#
eval "exec @PERL@ -S $0 $*"
if $running_under_some_shell;
# dump semaphore array values tony@divnc.com
require 'sys/sem.ph';
require 'getopts.pl';
&Getopts("vhi:k:"); # verbose, help, id, key
if ($opt_h || ($opt_i && $opt_k))
{
print STDERR <<NO_MORE_HELP;
semdump
Dump info about specified semaphore.
Usage: $0 [-v] { -i semid | -k semkey }
-v -- possibly more verbose
-i semid -- semaphore id
-k semkey -- semaphore key
-h -- help
anything else == this help message
NO_MORE_HELP
exit 1;
}
$verbose = $opt_v;
$id = $opt_i;
$key = $opt_k;
if ($key)
{
$key = oct($key) if $key =~ /^0/;
die "Could not convert key to id; $!" unless $id = semget($key, 1, 0);
}
# I don't know to find out how many sem's are attached to the id
# so just keep reading them until we get an error.
printf("KEY: 0x%X (%d) ", $key, $key) if $key;
print "ID: $id\n";
semlist:
for ($semnum=0; $semnum < 10; $semnum++)
{
$val = semctl($id, $semnum, &GETVAL, 0);
$val || ($val = -1);
last semlist if ($val == -1);
printf " %d: %d\n", $semnum, $val;
}
|