X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2FTestApp%2FController%2FFork.pm;h=086d1490445477dc28627aa8c876ce35f3e32162;hb=9c74923de2304b8c8f0a7a2faa0854ad9b4d3a92;hp=fb71c7c1795de8c9392a0e9400cfa62b912eff1d;hpb=09274aae9264de2d08cc7c38c8ca9bf304874b75;p=catagits%2FCatalyst-Runtime.git diff --git a/t/lib/TestApp/Controller/Fork.pm b/t/lib/TestApp/Controller/Fork.pm index fb71c7c..086d149 100644 --- a/t/lib/TestApp/Controller/Fork.pm +++ b/t/lib/TestApp/Controller/Fork.pm @@ -7,22 +7,55 @@ package TestApp::Controller::Fork; use strict; use warnings; use base 'Catalyst::Controller'; -use YAML; -sub fork : Global { +eval 'use YAML'; + +sub system : Local { my ($self, $c, $ls) = @_; my ($result, $code) = (undef, 1); if(!-e $ls || !-x _){ - $result = 'skip'; - $code = 0; + $result = 'skip'; } else { - $result = system($ls, $ls, $ls); - $code = $?; + $result = system($ls, $ls, $ls); + $result = $! if $result != 0; + } + + $c->response->body(Dump({result => $result})); +} + +sub backticks : Local { + my ($self, $c, $ls) = @_; + my ($result, $code) = (undef, 1); + + if(!-e $ls || !-x _){ + $result = 'skip'; + $code = 0; + } + else { + $result = `$ls $ls $ls` || $!; + $code = $?; } $c->response->body(Dump({result => $result, code => $code})); } +sub fork : Local { + my ($self, $c) = @_; + my $pid; + my $x = 0; + + if($pid = fork()){ + $x = "ok"; + } + else { + exit(0); + } + + waitpid $pid,0 or die; + + $c->response->body(Dump({pid => $pid, result => $x})); +} + 1;