| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
################################################################################ |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# Version 2.x, Copyright (C) 2007-2013, Marcus Holland-Moritz . |
|
4
|
|
|
|
|
|
|
# Version 1.x, Copyright (C) 1997, Graham Barr . |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or |
|
7
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
################################################################################ |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package IPC::Msg; |
|
12
|
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
448
|
use IPC::SysV qw(IPC_STAT IPC_SET IPC_RMID); |
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
41
|
|
|
14
|
1
|
|
|
1
|
|
3
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
21
|
|
|
15
|
1
|
|
|
1
|
|
2
|
use vars qw($VERSION); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
25
|
|
|
16
|
1
|
|
|
1
|
|
3
|
use Carp; |
|
|
1
|
|
|
|
|
0
|
|
|
|
1
|
|
|
|
|
78
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$VERSION = '2.07'; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Figure out if we have support for native sized types |
|
21
|
|
|
|
|
|
|
my $N = do { my $foo = eval { pack "L!", 0 }; $@ ? '' : '!' }; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
{ |
|
24
|
|
|
|
|
|
|
package IPC::Msg::stat; |
|
25
|
|
|
|
|
|
|
|
|
26
|
1
|
|
|
1
|
|
531
|
use Class::Struct qw(struct); |
|
|
1
|
|
|
|
|
1270
|
|
|
|
1
|
|
|
|
|
4
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
struct 'IPC::Msg::stat' => [ |
|
29
|
|
|
|
|
|
|
uid => '$', |
|
30
|
|
|
|
|
|
|
gid => '$', |
|
31
|
|
|
|
|
|
|
cuid => '$', |
|
32
|
|
|
|
|
|
|
cgid => '$', |
|
33
|
|
|
|
|
|
|
mode => '$', |
|
34
|
|
|
|
|
|
|
qnum => '$', |
|
35
|
|
|
|
|
|
|
qbytes => '$', |
|
36
|
|
|
|
|
|
|
lspid => '$', |
|
37
|
|
|
|
|
|
|
lrpid => '$', |
|
38
|
|
|
|
|
|
|
stime => '$', |
|
39
|
|
|
|
|
|
|
rtime => '$', |
|
40
|
|
|
|
|
|
|
ctime => '$', |
|
41
|
|
|
|
|
|
|
]; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub new { |
|
45
|
1
|
50
|
|
1
|
1
|
17
|
@_ == 3 || croak 'new IPC::Msg ( KEY , FLAGS )'; |
|
46
|
1
|
|
|
|
|
1
|
my $class = shift; |
|
47
|
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
17
|
my $id = msgget($_[0],$_[1]); |
|
49
|
|
|
|
|
|
|
|
|
50
|
1
|
50
|
|
|
|
11
|
defined($id) |
|
51
|
|
|
|
|
|
|
? bless \$id, $class |
|
52
|
|
|
|
|
|
|
: undef; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub id { |
|
56
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
57
|
0
|
|
|
|
|
0
|
$$self; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub stat { |
|
61
|
2
|
|
|
2
|
1
|
598
|
my $self = shift; |
|
62
|
2
|
|
|
|
|
2
|
my $data = ""; |
|
63
|
2
|
50
|
|
|
|
7
|
msgctl($$self,IPC_STAT,$data) or |
|
64
|
|
|
|
|
|
|
return undef; |
|
65
|
2
|
|
|
|
|
42
|
IPC::Msg::stat->new->unpack($data); |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub set { |
|
69
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
70
|
0
|
|
|
|
|
0
|
my $ds; |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
0
|
|
|
|
0
|
if(@_ == 1) { |
|
73
|
0
|
|
|
|
|
0
|
$ds = shift; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
else { |
|
76
|
0
|
0
|
|
|
|
0
|
croak 'Bad arg count' if @_ % 2; |
|
77
|
0
|
|
|
|
|
0
|
my %arg = @_; |
|
78
|
0
|
0
|
|
|
|
0
|
$ds = $self->stat |
|
79
|
|
|
|
|
|
|
or return undef; |
|
80
|
0
|
|
|
|
|
0
|
my($key,$val); |
|
81
|
0
|
|
|
|
|
0
|
$ds->$key($val) |
|
82
|
|
|
|
|
|
|
while(($key,$val) = each %arg); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
0
|
msgctl($$self,IPC_SET,$ds->pack); |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub remove { |
|
89
|
1
|
|
|
1
|
1
|
434
|
my $self = shift; |
|
90
|
1
|
|
|
|
|
6
|
(msgctl($$self,IPC_RMID,0), undef $$self)[0]; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub rcv { |
|
94
|
1
|
50
|
33
|
1
|
1
|
6
|
@_ <= 5 && @_ >= 3 or croak '$msg->rcv( BUF, LEN, TYPE, FLAGS )'; |
|
95
|
1
|
|
|
|
|
1
|
my $self = shift; |
|
96
|
1
|
|
|
|
|
2
|
my $buf = ""; |
|
97
|
1
|
50
|
50
|
|
|
13
|
msgrcv($$self,$buf,$_[1],$_[2] || 0, $_[3] || 0) or |
|
|
|
|
50
|
|
|
|
|
|
98
|
|
|
|
|
|
|
return; |
|
99
|
1
|
|
|
|
|
1
|
my $type; |
|
100
|
1
|
|
|
|
|
7
|
($type,$_[0]) = unpack("l$N a*",$buf); |
|
101
|
1
|
|
|
|
|
2
|
$type; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub snd { |
|
105
|
1
|
50
|
33
|
1
|
1
|
8
|
@_ <= 4 && @_ >= 3 or croak '$msg->snd( TYPE, BUF, FLAGS )'; |
|
106
|
1
|
|
|
|
|
2
|
my $self = shift; |
|
107
|
1
|
|
50
|
|
|
20
|
msgsnd($$self,pack("l$N a*",$_[0],$_[1]), $_[2] || 0); |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
__END__ |