line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Child::Link::IPC; |
2
|
10
|
|
|
10
|
|
54
|
use strict; |
|
10
|
|
|
|
|
21
|
|
|
10
|
|
|
|
|
355
|
|
3
|
10
|
|
|
10
|
|
51
|
use warnings; |
|
10
|
|
|
|
|
10
|
|
|
10
|
|
|
|
|
213
|
|
4
|
|
|
|
|
|
|
|
5
|
10
|
|
|
10
|
|
35
|
use Child::Util; |
|
10
|
|
|
|
|
8
|
|
|
10
|
|
|
|
|
379
|
|
6
|
|
|
|
|
|
|
|
7
|
10
|
|
|
10
|
|
32
|
use base 'Child::Link'; |
|
10
|
|
|
|
|
10
|
|
|
10
|
|
|
|
|
3403
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
add_accessors qw/ipc/; |
10
|
|
|
|
|
|
|
add_abstract qw/ |
11
|
|
|
|
|
|
|
read_handle |
12
|
|
|
|
|
|
|
write_handle |
13
|
|
|
|
|
|
|
/; |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
0
|
1
|
0
|
sub init {} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
21
|
|
|
21
|
1
|
80
|
my $class = shift; |
19
|
21
|
|
|
|
|
257
|
my ( $pid, @shared ) = @_; |
20
|
21
|
|
|
|
|
429
|
my $self = $class->SUPER::new($pid); |
21
|
21
|
|
|
|
|
283
|
$self->init( @shared ); |
22
|
21
|
|
|
|
|
48
|
return $self; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub autoflush { |
26
|
28
|
|
|
28
|
1
|
44
|
my $self = shift; |
27
|
28
|
|
|
|
|
41
|
my ( $value ) = @_; |
28
|
28
|
|
|
|
|
169
|
my $write = $self->write_handle; |
29
|
|
|
|
|
|
|
|
30
|
28
|
|
|
|
|
212
|
my $selected = select( $write ); |
31
|
28
|
100
|
|
|
|
352
|
$| = $value if @_; |
32
|
28
|
|
|
|
|
88
|
my $out = $|; |
33
|
|
|
|
|
|
|
|
34
|
28
|
|
|
|
|
172
|
select( $selected ); |
35
|
|
|
|
|
|
|
|
36
|
28
|
|
|
|
|
239
|
return $out; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub flush { |
40
|
2
|
|
|
2
|
1
|
5000153
|
my $self = shift; |
41
|
2
|
|
|
|
|
8
|
my $orig = $self->autoflush(); |
42
|
2
|
|
|
|
|
15
|
$self->autoflush(1); |
43
|
2
|
|
|
|
|
16
|
my $write = $self->write_handle; |
44
|
2
|
|
|
|
|
11
|
$self->autoflush($orig); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub read { |
48
|
23
|
|
|
23
|
1
|
345
|
my $self = shift; |
49
|
23
|
|
|
|
|
119
|
my $handle = $self->read_handle; |
50
|
23
|
|
|
|
|
13054357
|
return <$handle>; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub say { |
54
|
13
|
|
|
13
|
1
|
1071
|
my $self = shift; |
55
|
13
|
|
|
|
|
54
|
$self->write( map {$_ . $/} @_ ); |
|
13
|
|
|
|
|
225
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub write { |
59
|
13
|
|
|
13
|
1
|
26
|
my $self = shift; |
60
|
13
|
|
|
|
|
55
|
my $handle = $self->write_handle; |
61
|
13
|
|
|
|
|
2483
|
print $handle @_; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 NAME |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Child::Link::IPC - Base class for process links that provide IPC. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 SEE ALSO |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
This class inherits from: |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=over 4 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item L |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=back |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 METHODS |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=over 4 |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item $proc->new( $pid. @shared ) |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Constructor |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item $proc->read() |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Read a message from the child. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item $proc->write( @MESSAGES ) |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Send the messages to the child. works like print, you must add "\n". |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item $proc->say( @MESSAGES ) |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Send the messages to the child. works like say, adds the separator for you |
99
|
|
|
|
|
|
|
(usually "\n"). |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item $proc->autoflush( $BOOL ) |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Turn autoflush on/off for the current processes write handle. This is on by |
104
|
|
|
|
|
|
|
default. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item $proc->flush() |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Flush the current processes write handle. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item $proc->ipc() |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item $proc->_ipc( $new ) |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Accessors for you to use or ignore. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=back |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 ABSTRACT METHODS |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=over 4 |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item $proc->read_handle() |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Should return a read handle for reading from the child. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item $proc->write_handle() |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Should return a write handle for writing to the child. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item $proc->init( @shared ) |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Called by new during construction |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=back |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 HISTORY |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Most of this was part of L intended for use in the L |
139
|
|
|
|
|
|
|
project. Fennec is being broken into multiple parts, this is one such part. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 FENNEC PROJECT |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
This module is part of the Fennec project. See L for more details. |
144
|
|
|
|
|
|
|
Fennec is a project to develop an extendable and powerful testing framework. |
145
|
|
|
|
|
|
|
Together the tools that make up the Fennec framework provide a potent testing |
146
|
|
|
|
|
|
|
environment. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
The tools provided by Fennec are also useful on their own. Sometimes a tool |
149
|
|
|
|
|
|
|
created for Fennec is useful outside the greater framework. Such tools are |
150
|
|
|
|
|
|
|
turned into their own projects. This is one such project. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=over 2 |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item L - The core framework |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
The primary Fennec project that ties them all together. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=back |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 AUTHORS |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Chad Granum L |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 COPYRIGHT |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Copyright (C) 2010 Chad Granum |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Child is free software; Standard perl licence. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Child is distributed in the hope that it will be useful, but WITHOUT |
171
|
|
|
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
172
|
|
|
|
|
|
|
FOR A PARTICULAR PURPOSE. See the license for more details. |