line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Child::Link::IPC::Socket::Proc; |
2
|
9
|
|
|
9
|
|
39
|
use strict; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
261
|
|
3
|
9
|
|
|
9
|
|
45
|
use warnings; |
|
9
|
|
|
|
|
21
|
|
|
9
|
|
|
|
|
198
|
|
4
|
|
|
|
|
|
|
|
5
|
9
|
|
|
9
|
|
11709
|
use IO::Socket::UNIX; |
|
9
|
|
|
|
|
262530
|
|
|
9
|
|
|
|
|
78
|
|
6
|
9
|
|
|
9
|
|
5952
|
use Carp qw/croak/; |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
372
|
|
7
|
|
|
|
|
|
|
|
8
|
9
|
|
|
|
|
7767
|
use base qw/ |
9
|
|
|
|
|
|
|
Child::Link::IPC::Socket |
10
|
|
|
|
|
|
|
Child::Link::Proc |
11
|
9
|
|
|
9
|
|
45
|
/; |
|
9
|
|
|
|
|
15
|
|
12
|
|
|
|
|
|
|
|
13
|
16
|
|
|
16
|
0
|
412
|
sub socket_pid { shift->pid }; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub post_init { |
16
|
16
|
|
|
16
|
0
|
64
|
my $self = shift; |
17
|
16
|
|
|
|
|
136
|
$self->connect( 5 ); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new_from_file { |
21
|
2
|
|
|
2
|
0
|
15
|
my $class = shift; |
22
|
2
|
|
|
|
|
6
|
my ( $file ) = @_; |
23
|
2
|
|
|
|
|
30
|
my $self = bless( { _socket_file => $file }, $class ); |
24
|
2
|
|
|
|
|
13
|
my $pid = $self->connect( 5 ); |
25
|
2
|
|
|
|
|
34
|
$self->_pid( $pid ); |
26
|
2
|
|
|
|
|
25
|
return $self; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub connect { |
30
|
18
|
|
|
18
|
0
|
28
|
my $self = shift; |
31
|
18
|
50
|
|
|
|
194
|
return if $self->connected; |
32
|
18
|
|
|
|
|
348
|
my ( $timeout ) = @_; |
33
|
|
|
|
|
|
|
|
34
|
18
|
|
|
|
|
131
|
my $file = $self->socket_file; |
35
|
18
|
|
66
|
|
|
2987
|
while ( ! -e $file && $timeout ) { |
36
|
14
|
|
|
|
|
34
|
$timeout--; |
37
|
14
|
|
|
|
|
14003094
|
sleep 1; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
18
|
50
|
|
|
|
364
|
return unless -e $file; |
41
|
|
|
|
|
|
|
|
42
|
18
|
|
33
|
|
|
655
|
my $socket = IO::Socket::UNIX->new( $file ) |
43
|
|
|
|
|
|
|
|| croak ( "Could not connect to socket '" . $file . "': $!" ); |
44
|
|
|
|
|
|
|
|
45
|
18
|
|
|
|
|
18594
|
$self->_ipc( $socket ); |
46
|
18
|
|
|
|
|
251
|
$self->_connected( 1 ); |
47
|
18
|
|
|
|
|
16251
|
chomp( my $pid = <$socket> ); |
48
|
|
|
|
|
|
|
|
49
|
18
|
|
|
|
|
133
|
return $pid; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 NAME |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Child::Link::IPC::Socket::Proc - Socket based link to child process. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 SEE ALSO |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
L |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 AUTHORS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Chad Granum L |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 COPYRIGHT |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Copyright (C) 2010 Chad Granum |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Child is free software; Standard perl licence. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Child is distributed in the hope that it will be useful, but WITHOUT |
73
|
|
|
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
74
|
|
|
|
|
|
|
FOR A PARTICULAR PURPOSE. See the license for more details. |