| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package AnyEvent::Subprocess::Done; |
|
2
|
|
|
|
|
|
|
BEGIN { |
|
3
|
1
|
|
|
1
|
|
18383
|
$AnyEvent::Subprocess::Done::VERSION = '1.102912'; |
|
4
|
|
|
|
|
|
|
} |
|
5
|
|
|
|
|
|
|
# ABSTRACT: represents a completed subprocess run |
|
6
|
1
|
|
|
1
|
|
1344
|
use Moose; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use namespace::autoclean; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use AnyEvent::Subprocess::Types qw(DoneDelegate); |
|
10
|
|
|
|
|
|
|
use POSIX qw(WIFEXITED WEXITSTATUS WIFSIGNALED WIFEXITED WTERMSIG); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'AnyEvent::Subprocess::Role::WithDelegates' => { |
|
13
|
|
|
|
|
|
|
type => DoneDelegate, |
|
14
|
|
|
|
|
|
|
}; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# $? is the exit_status, the argument to exit ("exit 0") is exit_value |
|
17
|
|
|
|
|
|
|
# if the process was killed, exit_signal contains the signal that killed it |
|
18
|
|
|
|
|
|
|
has 'exit_status' => ( |
|
19
|
|
|
|
|
|
|
is => 'ro', |
|
20
|
|
|
|
|
|
|
isa => 'Int', |
|
21
|
|
|
|
|
|
|
required => 1, |
|
22
|
|
|
|
|
|
|
); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has [qw[dumped_core exited]] => ( |
|
25
|
|
|
|
|
|
|
is => 'ro', |
|
26
|
|
|
|
|
|
|
isa => 'Bool', |
|
27
|
|
|
|
|
|
|
lazy_build => 1, |
|
28
|
|
|
|
|
|
|
); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has [qw[exit_value exit_signal]] => ( |
|
31
|
|
|
|
|
|
|
is => 'ro', |
|
32
|
|
|
|
|
|
|
isa => 'Int', |
|
33
|
|
|
|
|
|
|
lazy_build => 1, |
|
34
|
|
|
|
|
|
|
); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _build_exited { |
|
37
|
|
|
|
|
|
|
my $self = shift; |
|
38
|
|
|
|
|
|
|
return WIFEXITED($self->exit_status); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _build_exit_value { |
|
42
|
|
|
|
|
|
|
my $self = shift; |
|
43
|
|
|
|
|
|
|
return WEXITSTATUS($self->exit_status); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _build_exit_signal { |
|
47
|
|
|
|
|
|
|
my $self = shift; |
|
48
|
|
|
|
|
|
|
return WIFSIGNALED($self->exit_status) && WTERMSIG($self->exit_status); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _build_dumped_core { |
|
52
|
|
|
|
|
|
|
my $self = shift; |
|
53
|
|
|
|
|
|
|
return 0 if $self->exit_status < 0; |
|
54
|
|
|
|
|
|
|
return $self->exit_status & 128; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub is_success { |
|
58
|
|
|
|
|
|
|
my $self = shift; |
|
59
|
|
|
|
|
|
|
return $self->exit_status == 0; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=pod |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 NAME |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
AnyEvent::Subprocess::Done - represents a completed subprocess run |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 VERSION |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
version 1.102912 |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
We are C<$done> in a sequence like: |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my $job = AnyEvent::Subprocess->new ( ... ); |
|
83
|
|
|
|
|
|
|
my $run = $job->run; |
|
84
|
|
|
|
|
|
|
$run->delegate('stdin')->push_write('Hello, my child!'); |
|
85
|
|
|
|
|
|
|
say "Running child as ", $run->child_pid; |
|
86
|
|
|
|
|
|
|
$run->kill(11) if $you_enjoy_that_sort_of_thing; |
|
87
|
|
|
|
|
|
|
my $done = $job->delegate('completion_condvar')->recv; |
|
88
|
|
|
|
|
|
|
say "Child exited with signal ", $done->exit_signal; |
|
89
|
|
|
|
|
|
|
say "Child produced some stdout: ", |
|
90
|
|
|
|
|
|
|
$done->delegate('stdout_capture')->output; |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
An instance of this class is returned to your C<on_completion> |
|
95
|
|
|
|
|
|
|
callback when the child process exists. |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 METHODS |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 delegate( $name ) |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Returns the delegate named C<$name>. |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 exit_status |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
C<$?> from waitpid on the child. Parsed into the various fields |
|
106
|
|
|
|
|
|
|
below: |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 exit_value |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
The value the child supplied to C<exit>. (0 if "C<exit 0>", etc.) |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head2 exit_signal |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
The signal number the child was killed by, if any. |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 dumped_core |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
True if the child dumped core. |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 is_success |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
True if the exit_status is 0. If this is false, your process dumped |
|
123
|
|
|
|
|
|
|
core, exited due to a signal, or exited with a value other than 0. |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
L<AnyEvent::Subprocess> |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
L<AnyEvent::Subprocess::Role::WithDelegates> |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 AUTHOR |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Jonathan Rockway <jrockway@cpan.org> |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
This software is copyright (c) 2011 by Jonathan Rockway. |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
140
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=cut |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
__END__ |
|
146
|
|
|
|
|
|
|
|