line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Ryu::Async::Process; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
44
|
use strict; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
213
|
|
4
|
6
|
|
|
6
|
|
32
|
use warnings; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
322
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.020'; # VERSION |
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TEAM'; # AUTHORITY |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Ryu::Async::Process - wrapper around a forked process |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
This is an L subclass for interacting with L. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
6
|
|
|
6
|
|
1016
|
use mro; |
|
6
|
|
|
|
|
1645
|
|
|
6
|
|
|
|
|
40
|
|
20
|
|
|
|
|
|
|
|
21
|
6
|
|
|
6
|
|
186
|
use parent qw(IO::Async::Notifier); |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
32
|
|
22
|
|
|
|
|
|
|
|
23
|
6
|
|
|
6
|
|
437
|
use IO::Async::Process; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
1908
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head2 stdout |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
A L wrapper around the process STDOUT (fd1). |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub stdout { |
32
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
33
|
0
|
|
0
|
|
|
|
$self->{stdout} //= $self->ryu->from_stream( |
34
|
|
|
|
|
|
|
$self->process->fd(1) |
35
|
|
|
|
|
|
|
) |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 stderr |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
A L wrapper around the process STDOUT (fd1). |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub stderr { |
45
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
46
|
0
|
|
0
|
|
|
|
$self->{stderr} //= $self->ryu->from_stream( |
47
|
|
|
|
|
|
|
$self->process->fd(2) |
48
|
|
|
|
|
|
|
) |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub ryu { |
52
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
53
|
0
|
|
0
|
|
|
|
$self->{ryu} //= do { |
54
|
0
|
|
|
|
|
|
require Ryu::Async; |
55
|
0
|
|
|
|
|
|
$self->add_child( |
56
|
|
|
|
|
|
|
my $ryu = Ryu::Async->new |
57
|
|
|
|
|
|
|
); |
58
|
0
|
|
|
|
|
|
$ryu |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub configure { |
63
|
0
|
|
|
0
|
1
|
|
my ($self, %args) = @_; |
64
|
0
|
0
|
|
|
|
|
if(exists $args{process}) { |
65
|
0
|
|
|
|
|
|
my $process = delete $args{process}; |
66
|
0
|
|
|
|
|
|
$self->{process} = $process; |
67
|
0
|
|
|
|
|
|
$self->add_child($process); |
68
|
|
|
|
|
|
|
} |
69
|
0
|
|
|
|
|
|
return $self->next::method(%args); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 AUTHOR |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Tom Molesworth |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 LICENSE |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Copyright Tom Molesworth 2017-2021. Licensed under the same terms as Perl itself. |
81
|
|
|
|
|
|
|
|