Subprocess/Done.pm

filter: Statementstmt 100% 30 / 30 Branchbran 100% 2 / 2 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 10 / 10 Podpod 100% 1 / 1 totaltotal 95.8% 46 / 48 CC 3 SCAR 2.9
CC
3
Cov
97%
_build_exit_signal
2.0
_build_dumped_core
2.0
BEGIN
1.0
CRAP 1.3
« Subprocess/Running/Delegate/Callback.pm ↑ Summary Subprocess/Easy.pm »
1 package AnyEvent::Subprocess::Done;
2 48 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 48 $AnyEvent::Subprocess::Done::VERSION = '1.102912';
4 }
5 # ABSTRACT: represents a completed subprocess run
6 48 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 48 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 48 ▶use AnyEvent::Subprocess::Types qw(DoneDelegate);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 48 ▶use POSIX qw(WIFEXITED WEXITSTATUS WIFSIGNALED WIFEXITED WTERMSIG);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 47 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 47 has 'exit_status' => (
19 is => 'ro',
20 isa => 'Int',
21 required => 1,
22 );
23  
24 47 has [qw[dumped_core exited]] => (
25 is => 'ro',
26 isa => 'Bool',
27 lazy_build => 1,
28 );
29  
30 47 has [qw[exit_value exit_signal]] => (
31 is => 'ro',
32 isa => 'Int',
33 lazy_build => 1,
34 );
35  
36 3 ▶sub _build_exited {
Subroutine _build_exited: called CC=1 SCAR=0.0
37 3 my $self = shift;
38 3 return WIFEXITED($self->exit_status);
39 }
40  
41 13 ▶sub _build_exit_value {
Subroutine _build_exit_value: called CC=1 SCAR=0.0
42 13 my $self = shift;
43 13 return WEXITSTATUS($self->exit_status);
44 }
45  
46 3 ▶sub _build_exit_signal {
Subroutine _build_exit_signal: called CC=2 SCAR=7.1
47 3 my $self = shift;
48 3 ▶ return WIFSIGNALED($self->exit_status) && WTERMSIG($self->exit_status);
Condition66%2/3
WIFSIGNALED($self->exit_status) && WTERMSIG($self->exit_status)
!ll&&!rl&&r
201
MC/DC50%1/2
WIFSIGNALED($self->exit_status) && WTERMSIG($self->exit_status)
WIFSIGNALED($self->exit_status) WTERMSIG($self->exit_status)
Truth table66%2/3
A && B
A= WIFSIGNALED($self->exit_status)B= WTERMSIG($self->exit_status)
ABresult
0X0
100
111
49 }
50  
51 4 ▶sub _build_dumped_core {
Subroutine _build_dumped_core: called CC=2 SCAR=6.9
52 4 my $self = shift;
53 4 ▶ return 0 if $self->exit_status < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->exit_status < 0 1 3 4
54 3 return $self->exit_status & 128;
55 }
56  
57 12 ▶sub is_success {
Subroutine is_success: called CC=1 SCAR=0.0
Pod documented
58 12 my $self = shift;
59 12 return $self->exit_status == 0;
60 }
61  
62 47 __PACKAGE__->meta->make_immutable;
63  
64 47 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__
« Subprocess/Running/Delegate/Callback.pm ↑ Summary Subprocess/Easy.pm »