| 1 | package Process::Backgroundable; | ||
| 2 | |||
| 3 | 4 | ▶ | use 5.005; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 4 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 4 | ▶ | use Storable (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 4 | ▶ | use File::Temp (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 4 | ▶ | use IPC::Run3 (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 4 | ▶ | use Process::Storable (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 4 | ▶ | use vars qw{$VERSION @ISA @PERLCMD}; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 4 | ▶ | BEGIN { |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | 4 | $VERSION = '0.21'; | |
| 13 | 4 | @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 | 4 | @PERLCMD = ( $^X ); | |
| 20 | } | ||
| 21 | |||
| 22 | 1 | ▶ | sub background { |
|
Subroutine
background: called CC=1 SCAR=0.0
Pod
documented
| |||
| 23 | 1 | my $self = shift; | |
| 24 | |||
| 25 | # Dump the object to the input filehandle | ||
| 26 | 1 | my $stdin = File::Temp::tempfile(); | |
| 27 | 1 | $self->serialize( $stdin ); | |
| 28 | 1 | seek( $stdin, 0, 0 ); | |
| 29 | |||
| 30 | # Generate the command | ||
| 31 | 1 | my $cmd = [ @PERLCMD, '-MProcess::Launcher', '-e serialized', ref($self) ]; | |
| 32 | |||
| 33 | # Fire the command | ||
| 34 | 1 | IPC::Run3::run3( $cmd, $stdin, \undef, \undef ); | |
| 35 | |||
| 36 | 1 | return 1; | |
| 37 | } | ||
| 38 | |||
| 39 | 4 | 1; | |
| 40 | |||
| 41 | __END__ | ||