Fix Restarter::Watcher to support delay of 0
[catagits/Catalyst-Runtime.git] / t / lib / TestApp / Controller / Fork.pm
index fb71c7c..b6992ab 100644 (file)
@@ -9,7 +9,7 @@ use warnings;
 use base 'Catalyst::Controller';
 use YAML;
 
-sub fork : Global {
+sub system : Local {
     my ($self, $c, $ls) = @_;
     my ($result, $code) = (undef, 1);
 
@@ -18,11 +18,44 @@ sub fork : Global {
        $code = 0;
     }
     else {
-       $result = system($ls, $ls, $ls);
+       $result = system($ls, $ls, $ls) || $!;
        $code = $?;
     }
     
     $c->response->body(Dump({result => $result, code => $code}));
 }
 
+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;