File Coverage

blib/lib/Process/Backgroundable.pm
Criterion Covered Total %
statement 31 31 100.0
branch n/a
condition n/a
subroutine 9 9 100.0
pod 1 1 100.0
total 41 41 100.0


line stmt bran cond sub pod time code
1             package Process::Backgroundable;
2              
3 2     2   32734 use 5.005;
  2         7  
  2         78  
4 2     2   10 use strict;
  2         4  
  2         50  
5 2     2   2103 use Storable ();
  2         7684  
  2         44  
6 2     2   2924 use File::Temp ();
  2         54597  
  2         49  
7 2     2   42721 use IPC::Run3 ();
  2         60355  
  2         59  
8 2     2   2947 use Process::Storable ();
  2         47866  
  2         70  
9              
10 2     2   20 use vars qw{$VERSION @ISA @PERLCMD};
  2         5  
  2         191  
11             BEGIN {
12 2     2   5 $VERSION = '0.21';
13 2         49 @ISA = 'Process::Storable';
14              
15             # Contains the command to use to launch perl
16             # Should be the path to the perl current running.
17             # People with special needs should localise this
18             # to add any flags.
19 2         233 @PERLCMD = ( $^X );
20             }
21              
22             sub background {
23 1     1 1 2536 my $self = shift;
24              
25             # Dump the object to the input filehandle
26 1         9 my $stdin = File::Temp::tempfile();
27 1         790 $self->serialize( $stdin );
28 1         155 seek( $stdin, 0, 0 );
29              
30             # Generate the command
31 1         6 my $cmd = [ @PERLCMD, '-MProcess::Launcher', '-e serialized', ref($self) ];
32              
33             # Fire the command
34 1         6 IPC::Run3::run3( $cmd, $stdin, \undef, \undef );
35              
36 1         98654 return 1;
37             }
38              
39             1;
40              
41             __END__